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.
- checksums.yaml +4 -4
- data/lib/sinatra-statistics.rb +17 -8
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4d99bfdbd36bfe92541533e83218af7874a549f4
|
|
4
|
+
data.tar.gz: aff6e122234e7ee14aa2351771354d571ea9aaa1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 57bdeb95f4031006a89f19bf1c4cce265d1318a1eea496b265c3a488bccf71222e58b7b62a6a2e5d2592311d4e90c6cf7a282844a32cc5e3a7f1eebfe4e9bc46
|
|
7
|
+
data.tar.gz: a31f2cd1806dc27b7782ed0df5fe13fa4f934c02524a70da08f0601c125c5b82e67afbe768a0d69443956a4568845c09e5a8886eb3d0ab728f2234b222e51bcd
|
data/lib/sinatra-statistics.rb
CHANGED
|
@@ -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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|