def add_app_statistics(userid, platform, app, now=None): mark = partial(mark_event, now=now) if not now: now = timezone.now() appid = app.get('appid') version = app.get('version') channel = app.get('tag') or DEFAULT_CHANNEL events = app.findall('event') err_events = filter(lambda x: x.get('eventresult') not in ['1', '2', '3'], events) if err_events: return install_event = filter(lambda x: x.get('eventtype') == '2', events) if is_new_install(appid, userid): if install_event and install_event[0].get('eventresult') in ['1', '2', '3']: mark('new_install:%s' % appid, userid) mark('new_install:{}:{}'.format(appid, platform), userid) redis.setbit("known_users:%s" % appid, userid, 1) elif userid not in MonthEvents('new_install:{}:{}'.format(appid, platform), year=now.year, month=now.month): mark('request:%s' % appid, userid) mark('request:{}:{}'.format(appid, platform), userid) uninstall_event = filter(lambda x: x.get('eventtype') == '4', events) if uninstall_event and uninstall_event[0].get('eventresult') in ['1', '2', '3']: mark('uninstall:%s' % appid, userid) mark('uninstall:{}:{}'.format(appid, platform), userid) mark('request:{}:{}'.format(appid, version), userid) mark('request:{}:{}'.format(appid, channel), userid) mark('request:{}:{}:{}'.format(appid, platform, version), userid)
def add_app_statistics(userid, platform, app, now=None): mark = partial(mark_event, now=now) if not now: now = timezone.now() appid = app.get('appid') version = app.get('version') channel = parser.get_channel(app) events = app.findall('event') err_events = filter(lambda x: x.get('eventresult') not in ['1', '2', '3'], events) if err_events: return install_event = filter(lambda x: x.get('eventtype') == '2', events) if is_new_install(appid, userid): if install_event and install_event[0].get('eventresult') in ['1', '2', '3']: mark('new_install:%s' % appid, userid) mark('new_install:{}:{}'.format(appid, platform), userid) redis.setbit("known_users:%s" % appid, userid, 1) elif userid not in MonthEvents('new_install:{}:{}'.format(appid, platform), year=now.year, month=now.month): mark('request:%s' % appid, userid) mark('request:{}:{}'.format(appid, platform), userid) uninstall_event = filter(lambda x: x.get('eventtype') == '4', events) if uninstall_event and uninstall_event[0].get('eventresult') in ['1', '2', '3']: mark('uninstall:%s' % appid, userid) mark('uninstall:{}:{}'.format(appid, platform), userid) mark('request:{}:{}'.format(appid, version), userid) mark('request:{}:{}'.format(appid, channel), userid) mark('request:{}:{}:{}'.format(appid, platform, version), userid)
def add_app_statistics(userid, platform, app, now=None): mark = partial(mark_event, now=now) if not now: now = timezone.now() appid = app.get('appid') version = app.get('version') channel = parser.get_channel(app) events = app.findall('event') nextversion = app.get('nextversion') err_events = filter(lambda x: x.get('eventresult') not in ['1', '2', '3'], events) if err_events: return install_event = filter(lambda x: x.get('eventtype') == '2', events) if is_new_install(appid, userid): if install_event: mark('new_install:%s' % appid, userid) mark('new_install:{}:{}'.format(appid, platform), userid) redis.setbit("known_users:%s" % appid, userid, 1) mark('request:{}:{}'.format(appid, nextversion), userid, track_hourly=True) mark('request:{}:{}:{}'.format(appid, platform, nextversion), userid, track_hourly=True) mark('request:{}:{}:{}:{}'.format(appid, platform, channel, nextversion), userid, track_hourly=True) mark('request:{}:{}'.format(appid, channel), userid) return elif userid not in MonthEvents('new_install:{}:{}'.format(appid, platform), year=now.year, month=now.month): mark('request:%s' % appid, userid) mark('request:{}:{}'.format(appid, platform), userid) if nextversion: mark('request:{}:{}'.format(appid, nextversion), userid, track_hourly=True) mark('request:{}:{}:{}'.format(appid, platform, nextversion), userid, track_hourly=True) mark('request:{}:{}:{}:{}'.format(appid, platform, channel, nextversion), userid, track_hourly=True) uninstall_event = filter(lambda x: x.get('eventtype') == '4', events) if uninstall_event: mark('uninstall:%s' % appid, userid) mark('uninstall:{}:{}'.format(appid, platform), userid) update_event = filter(lambda x: x.get('eventtype') == '3', events) if update_event: unmark_event('request:{}:{}'.format(appid, version), userid, track_hourly=True) unmark_event('request:{}:{}:{}'.format(appid, platform, version), userid, track_hourly=True) unmark_event('request:{}:{}:{}:{}'.format(appid, platform, channel, version), userid, track_hourly=True) mark('request:{}:{}'.format(appid, nextversion), userid, track_hourly=True) mark('request:{}:{}:{}'.format(appid, platform, nextversion), userid, track_hourly=True) mark('request:{}:{}:{}:{}'.format(appid, platform, channel, nextversion), userid, track_hourly=True) else: mark('request:{}:{}'.format(appid, version), userid, track_hourly=True) mark('request:{}:{}:{}'.format(appid, platform, version), userid, track_hourly=True) mark('request:{}:{}:{}:{}'.format(appid, platform, channel, version), userid, track_hourly=True) mark('request:{}:{}'.format(appid, channel), userid)
def add_app_statistics(userid, platform, app, now=None): mark = partial(mark_event, now=now) if not now: now = timezone.now() appid = app.get('appid') version = app.get('version') channel = parser.get_channel(app) events = app.findall('event') nextversion = app.get('nextversion') err_events = [x for x in events if x.get('eventresult') not in ['1', '2', '3']] if err_events: return install_event = [x for x in events if x.get('eventtype') == '2'] if is_new_install(appid, userid): if install_event: mark('new_install:%s' % appid, userid) mark('new_install:{}:{}'.format(appid, platform), userid) redis.setbit("known_users:%s" % appid, userid, 1) mark('request:{}:{}'.format(appid, nextversion), userid, track_hourly=True) mark('request:{}:{}:{}'.format(appid, platform, nextversion), userid, track_hourly=True) mark('request:{}:{}:{}:{}'.format(appid, platform, channel, nextversion), userid, track_hourly=True) mark('request:{}:{}'.format(appid, channel), userid) return elif userid not in MonthEvents('new_install:{}:{}'.format(appid, platform), year=now.year, month=now.month): mark('request:%s' % appid, userid) mark('request:{}:{}'.format(appid, platform), userid) if nextversion: mark('request:{}:{}'.format(appid, nextversion), userid, track_hourly=True) mark('request:{}:{}:{}'.format(appid, platform, nextversion), userid, track_hourly=True) mark('request:{}:{}:{}:{}'.format(appid, platform, channel, nextversion), userid, track_hourly=True) uninstall_event = [x for x in events if x.get('eventtype') == '4'] if uninstall_event: mark('uninstall:%s' % appid, userid) mark('uninstall:{}:{}'.format(appid, platform), userid) update_event = [x for x in events if x.get('eventtype') == '3'] if update_event: unmark_event('request:{}:{}'.format(appid, version), userid, track_hourly=True) unmark_event('request:{}:{}:{}'.format(appid, platform, version), userid, track_hourly=True) unmark_event('request:{}:{}:{}:{}'.format(appid, platform, channel, version), userid, track_hourly=True) mark('request:{}:{}'.format(appid, nextversion), userid, track_hourly=True) mark('request:{}:{}:{}'.format(appid, platform, nextversion), userid, track_hourly=True) mark('request:{}:{}:{}:{}'.format(appid, platform, channel, nextversion), userid, track_hourly=True) else: mark('request:{}:{}'.format(appid, version), userid, track_hourly=True) mark('request:{}:{}:{}'.format(appid, platform, version), userid, track_hourly=True) mark('request:{}:{}:{}:{}'.format(appid, platform, channel, version), userid, track_hourly=True) mark('request:{}:{}'.format(appid, channel), userid)
def add_app_statistics(userid, platform, app, now=None): mark = partial(mark_event, now=now) if not now: now = timezone.now() appid = app.get('appid') version = app.get('version') channel = app.get('tag') or DEFAULT_CHANNEL if is_new_install(appid, userid): mark('new_install:%s' % appid, userid) mark('new_install:{}:{}'.format(appid, platform), userid) redis.setbit("known_users:%s" % appid, userid, 1) elif userid not in MonthEvents('new_install:{}:{}'.format(appid, platform), year=now.year, month=now.month): mark('request:%s' % appid, userid) mark('request:{}:{}'.format(appid, platform), userid) mark('request:{}:{}'.format(appid, version), userid) mark('request:{}:{}'.format(appid, channel), userid) mark('request:{}:{}:{}'.format(appid, platform, version), userid)