1
|
|
|
# coding: utf8 |
2
|
|
|
|
3
|
|
|
""" |
4
|
|
|
This software is licensed under the Apache 2 license, quoted below. |
5
|
|
|
|
6
|
|
|
Copyright 2016 Crystalnix Limited |
7
|
|
|
|
8
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not |
9
|
|
|
use this file except in compliance with the License. You may obtain a copy of |
10
|
|
|
the License at |
11
|
|
|
|
12
|
|
|
http://www.apache.org/licenses/LICENSE-2.0 |
13
|
|
|
|
14
|
|
|
Unless required by applicable law or agreed to in writing, software |
15
|
|
|
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
16
|
|
|
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
17
|
|
|
License for the specific language governing permissions and limitations under |
18
|
|
|
the License. |
19
|
|
|
""" |
20
|
|
|
|
21
|
|
|
from functools import partial |
22
|
|
|
|
23
|
|
|
from bitmapist import mark_event |
24
|
|
|
|
25
|
|
|
from omaha.statistics import get_id, add_app_statistics |
26
|
|
|
|
27
|
|
|
def collect_statistics(request, appid, channel, now=None): |
28
|
|
|
deviceID = request.GET.get('deviceID') |
29
|
|
|
version = request.GET.get('appVersionShort') |
30
|
|
|
if not deviceID or not version: |
31
|
|
|
return |
32
|
|
|
userid = get_id(deviceID) |
33
|
|
|
app = dict(appid=appid, |
34
|
|
|
version=version, |
35
|
|
|
tag=channel) |
36
|
|
|
mark_event('request', userid, now=now) |
37
|
|
|
|
38
|
|
|
add_app_statistics(userid, 'mac', app) |
39
|
|
|
update_live_statistics(userid, appid, version) |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
def update_live_statistics(userid, appid, version, now=None): |
43
|
|
|
mark = partial(mark_event, now=now, track_hourly=True) |
44
|
|
|
mark('online:{}:{}'.format(appid, version), userid) |
45
|
|
|
mark('online:{}:{}:{}'.format(appid, 'mac', version), userid) |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
|