sinatra-statistics 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sinatra-statistics.rb +17 -8
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45c3224d0d9a7577f70bb69f0cac37c7da5e49a0
4
- data.tar.gz: 1ff70c7a396e65942875cc6df04f173e3f7b40f5
3
+ metadata.gz: 4d99bfdbd36bfe92541533e83218af7874a549f4
4
+ data.tar.gz: aff6e122234e7ee14aa2351771354d571ea9aaa1
5
5
  SHA512:
6
- metadata.gz: 78913a0d7415d41f7d90db321902a32df4630d00384c38e5f8579a1fe6cf1e26567dfa830943174e8520e132541239ac89c44a323e6cc7a6727e497a61939df9
7
- data.tar.gz: 9a5cb0d53c8bd86a8ef6ffecd9489320c6359e314650acc00c6b9773bdd75a239ee763e95c75469166132fbb8dd23fcb5fca4d1e24d3d607825ad2b37217e6db
6
+ metadata.gz: 57bdeb95f4031006a89f19bf1c4cce265d1318a1eea496b265c3a488bccf71222e58b7b62a6a2e5d2592311d4e90c6cf7a282844a32cc5e3a7f1eebfe4e9bc46
7
+ data.tar.gz: a31f2cd1806dc27b7782ed0df5fe13fa4f934c02524a70da08f0601c125c5b82e67afbe768a0d69443956a4568845c09e5a8886eb3d0ab728f2234b222e51bcd
@@ -117,15 +117,24 @@ module Statistics
117
117
  end
118
118
  get "/extension/statistics/month_list/:month_count" do |month_count|
119
119
  month_count = month_count.to_i
120
- this_month = Date.today
121
- (2).upto(month_count).each {|x| this_month=this_month.prev_month}
122
- prev_month_str = this_month.to_s.gsub("-","")[0..5]
123
- all_data = $statistics_db.get_data()
124
- new_data = all_data.select do |record|
125
- # [record["id"], prev_month_str, (record["id"] >= prev_month_str)].ppt
126
- record["type"] == Statistics::TYPE_MONTH and record["id"] >= prev_month_str
120
+ if month_count > 0
121
+ this_month = Date.today
122
+ (2).upto(month_count).each {|x| this_month=this_month.prev_month}
123
+ prev_month_str = this_month.to_s.gsub("-","")[0..5]
124
+ all_data = $statistics_db.get_data()
125
+ new_data = all_data.select do |record|
126
+ # [record["id"], prev_month_str, (record["id"] >= prev_month_str)].ppt
127
+ record["type"] == Statistics::TYPE_MONTH and record["id"] >= prev_month_str
128
+ end
129
+ new_data.to_json
130
+ else
131
+ all_data = $statistics_db.get_data()
132
+ new_data = all_data.select do |record|
133
+ # [record["id"], prev_month_str, (record["id"] >= prev_month_str)].ppt
134
+ record["type"] == Statistics::TYPE_MONTH
135
+ end
136
+ new_data.to_json
127
137
  end
128
- new_data.to_json
129
138
  end
130
139
  get "/extension/statistics/day_list_at_this_month" do
131
140
  this_month = Date.today
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-statistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin Ji