tdiary-io-mongodb 5.0.4 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1dbb313bf04bf09d959c9ea57eb37c5342801a29524fa5a7e490ed5cd2025f54
4
- data.tar.gz: 128f0db04b7e0aa40e94043657997c237dbdeebcf64cbe25050b596d30776d78
3
+ metadata.gz: e238fc1411ee9e6c2799b957680df12df93b21e615d7cd1b6710a923fc94946a
4
+ data.tar.gz: bf84b576fdfca7607fda1f7b9b554f40f2ca3193c2e96590a1175bab348c5887
5
5
  SHA512:
6
- metadata.gz: fd954eea0cc1551da811e56aa8c867e74e2d30328ddd9ee2d536a981ac3e0b666f319761c11f16b4f82935761fa9add99db9ee74586c06e0819acb4049b70994
7
- data.tar.gz: ba9a44e34fc95e3660e61a883fd66e18259b6ecfa3581b67fc2774b7fd2d50158c63fd64d1a667d3c6ebdbcb76a27130d88a4c0c284a490fbf120262921e6d14
6
+ metadata.gz: d39177a691525bf37a60c4f0bec0673db8c24487d9d7cd9ab6081f206ddbf4a1b478ab67601fc7fead882950c724644b90ddd87e526e867f9b65e1329812fb24
7
+ data.tar.gz: 95d8171ea0a0094f2b468e3dd10634a77b948609a7bd7aea98f26925e0440cca9c37fc8d318ef1702fcb8aabb1715352d022b9062c37a7ffd868721ec6ad4592
@@ -183,9 +183,15 @@ module TDiary
183
183
  end
184
184
 
185
185
  def calendar
186
+ mongo_project = {
187
+ "$group" => {
188
+ "_id" => {"year" => "$year", "month" => "$month"},
189
+ "count" => {"$sum" => 1}
190
+ }
191
+ }
186
192
  calendar = Hash.new{|hash, key| hash[key] = []}
187
- Diary.all.map{|d|[d.year, d.month]}.sort.uniq.each do |ym|
188
- calendar[ym[0]] << ym[1]
193
+ Diary.collection.aggregate([mongo_project]).map do |cal|
194
+ calendar[cal['_id']['year']] << cal['_id']['month']
189
195
  end
190
196
  calendar
191
197
  end
@@ -4,8 +4,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "tdiary-io-mongodb"
7
- spec.version = "5.0.4"
8
- spec.authors = ["TADA Tadashi"]
7
+ spec.version = "5.1.0"
8
+ spec.authors = ["Tada, Tadashi"]
9
9
  spec.email = ["t@tdtds.jp"]
10
10
  spec.description = %q{MongoDB adapter for tDiary}
11
11
  spec.summary = %q{MongoDB adapter for tDiary}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdiary-io-mongodb
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.4
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - TADA Tadashi
7
+ - Tada, Tadashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-25 00:00:00.000000000 Z
11
+ date: 2020-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0'
163
163
  requirements: []
164
- rubygems_version: 3.0.3
164
+ rubygems_version: 3.1.2
165
165
  signing_key:
166
166
  specification_version: 4
167
167
  summary: MongoDB adapter for tDiary