def get(self, request, app_name, format=None): app = self.get_object(app_name) now = timezone.now() dates = LiveStatisticsRangeSerializer(data=request.GET) dates.is_valid() end = dates.validated_data.get('end', now) start = dates.validated_data.get('start', end - datetime.timedelta(hours=24)) data = get_users_live_versions(app.id, start, end, tz=request.session.get('django_timezone', 'UTC')) serializer = StatisticsMonthsSerializer(dict(data=dict(data))) return Response(serializer.data)
def get(self, request, app_name, format=None): app = self.get_object(app_name) now = timezone.now() dates = LiveStatisticsRangeSerializer(data=request.GET) dates.is_valid() end = dates.validated_data.get('end', now) start = dates.validated_data.get('start', end - datetime.timedelta(hours=24)) data = get_users_live_versions(app.id, start, end, tz=request.session.get('django_timezone', 'UTC')) serializer = StatisticsMonthsSerializer(dict(data=dict(data))) return Response(serializer.data)
def get(self, request, app_name, format=None): import logging logging.info('Starting working in view') app = self.get_object(app_name) now = timezone.now() data = LiveStatisticsInputSerializer(data=request.GET) data.is_valid() end = data.validated_data.get('end', now) start = data.validated_data.get('start', end - datetime.timedelta(hours=24)) channel = data.validated_data.get('channel') data = get_users_live_versions(app.id, start, end, channel, tz=request.session.get('django_timezone', 'UTC')) logging.info('Getting data is finished') serializer = StatisticsMonthsSerializer(dict(data=dict(data))) return Response(serializer.data)
def generate_version(self, is_enabled): app = Application.objects.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='app') platform = Platform.objects.create(name='win') channel = Channel.objects.create(name='stable') userid = 1 Version.objects.create( is_enabled=is_enabled, app=app, platform=platform, channel=channel, version='0.0.0.2', file=SimpleUploadedFile('./chrome_installer.exe', False)) start = timezone.now() - timedelta(3) end = timezone.now() request = parse_request(fixtures.request_event_uninstall_success) apps = request.findall('app') userid_counting(userid, apps, platform) return get_users_live_versions( app_id=app.pk, channel=channel, start=start, end=end, )
def get(self, request, app_name, format=None): app = self.get_object(app_name) data = get_users_live_versions(app.id, tz=request.session.get('django_timezone', 'UTC')) serializer = StatisticsMonthsSerializer(dict(data=dict(data))) return Response(serializer.data)