@@ 185-203 (lines=19) @@ | ||
182 | ||
183 | ||
184 | ||
185 | def get_hourly_data_by_platform(app_id, end, n_hours, versions, platform, channel, tz='UTC'): |
|
186 | def build_event_name(app_id, platform, channel, v): |
|
187 | if channel: |
|
188 | return "request:{}:{}:{}:{}".format(app_id, platform, channel, v) |
|
189 | else: |
|
190 | return "request:{}:{}:{}".format(app_id, platform, v) |
|
191 | ||
192 | tzinfo = pytz.timezone(tz) |
|
193 | start = end - timezone.timedelta(hours=n_hours) |
|
194 | ||
195 | hours = [datetime(start.year, start.month, start.day, start.hour, tzinfo=pytz.UTC) |
|
196 | + timezone.timedelta(hours=x) for x in range(1, n_hours + 1)] |
|
197 | ||
198 | data = [(v, [[hour.astimezone(tzinfo).strftime("%Y-%m-%dT%H:%M:%S.%fZ"), |
|
199 | len(HourEvents.from_date(build_event_name(app_id, platform, channel, v), hour))] |
|
200 | for hour in hours]) |
|
201 | for v in versions] |
|
202 | data = filter(lambda version_data: sum([data[1] for data in version_data[1]]), data) |
|
203 | return dict(data) |
|
204 | ||
205 | ||
206 | def get_daily_data_by_platform(app_id, end, n_days, versions, platform, channel): |
|
@@ 206-221 (lines=16) @@ | ||
203 | return dict(data) |
|
204 | ||
205 | ||
206 | def get_daily_data_by_platform(app_id, end, n_days, versions, platform, channel): |
|
207 | def build_event_name(app_id, platform, channel, v): |
|
208 | if channel: |
|
209 | return "request:{}:{}:{}:{}".format(app_id, platform, channel, v) |
|
210 | else: |
|
211 | return "request:{}:{}:{}".format(app_id, platform, v) |
|
212 | ||
213 | start = end - timezone.timedelta(days=n_days) |
|
214 | ||
215 | days = [start + timezone.timedelta(days=x) for x in range(0, n_days+1)] |
|
216 | data = [(v, [[day.strftime("%Y-%m-%dT00:%M:%S.%fZ"), |
|
217 | len(DayEvents.from_date(build_event_name(app_id, platform, channel, v), day))] |
|
218 | for day in days]) |
|
219 | for v in versions] |
|
220 | data = filter(lambda version_data: sum([data[1] for data in version_data[1]]), data) |
|
221 | return dict(data) |
|
222 | ||
223 | ||
224 | def get_users_live_versions(app_id, start, end, channel, tz='UTC'): |