Пример #1
0
    def get_context_data(self, **kwargs):
        context = super(StatisticsDetailView, self).get_context_data(**kwargs)

        app = self.object
        form = self.get_form()
        form.is_valid()

        now = timezone.now()
        last_week = now - datetime.timedelta(days=7)

        start, end = get_month_range_from_dict(form.cleaned_data)

        diapasons = [((start.month if year == start.year else 1, end.month if year == end.year else 12), year)
                     for year in range(start.year, end.year+1)]

        data = []
        for diapason in diapasons:
            data += get_users_statistics_months(app_id=app.id, year=diapason[1], start=diapason[0][0], end=diapason[0][1])

        qs = AppRequest.objects.filter(appid=app.id,
                                       request__created__range=[last_week, now])

        context['range_start'] = start.strftime('%B %Y')
        context['range_end'] = end.strftime('%B %Y')
        context['install_count'] = qs.filter(events__eventtype=2).count()
        context['update_count'] = qs.filter(events__eventtype=3).count()

        context['months'] = make_discrete_bar_chart('months', data)
        context['weeks'] = make_discrete_bar_chart('weeks', get_users_statistics_weeks(app_id=app.id))
        context['versions'] = make_piechart('versions', get_users_versions(app.id))
        context['channels'] = make_piechart('channels', get_channel_statistics(app.id))
        versions_data = [dict(version=x[0], number=x[1]) for x in get_users_versions(app.id)]
        context['versions_table'] = VersionsTable(versions_data)
        context['form'] = form
        return context
    def get_context_data(self, **kwargs):
        context = super(StatisticsDetailView, self).get_context_data(**kwargs)

        app = self.object

        now = timezone.now()
        last_week = now - datetime.timedelta(days=7)

        qs = AppRequest.objects.filter(appid=app.id,
                                       request__created__range=[last_week, now])

        context['install_count'] = qs.filter(events__eventtype=2).count()
        context['update_count'] = qs.filter(events__eventtype=3).count()

        context['months'] = make_discrete_bar_chart('months', get_users_statistics_months(app_id=app.id))
        context['weeks'] = make_discrete_bar_chart('weeks', get_users_statistics_weeks(app_id=app.id))
        context['versions'] = make_piechart('versions', get_users_versions(app.id))
        context['channels'] = make_piechart('channels', get_channel_statistics(app.id))

        return context
Пример #3
0
 def test_make_piechart(self):
     data = [('apple', 10), ('orange', 3)]
     self.assertDictEqual(make_piechart('test', data),
                          {'chartcontainer': 'chart_container_test',
                           'chartdata': {
                               'extra1': {'tooltip': {'y_end': ' users', 'y_start': ''}},
                               'x': ['apple', 'orange'],
                               'y1': [10, 3]},
                           'charttype': 'pieChart',
                           'extra': {'jquery_on_ready': False,
                                     'tag_script_js': True,
                                     'x_axis_format': '',
                                     'x_is_date': False}})
Пример #4
0
    def get_context_data(self, **kwargs):
        context = super(StatisticsDetailView, self).get_context_data(**kwargs)

        app = self.object

        now = timezone.now()
        last_week = now - datetime.timedelta(days=7)

        qs = AppRequest.objects.filter(
            appid=app.id, request__created__range=[last_week, now])

        context['install_count'] = qs.filter(events__eventtype=2).count()
        context['update_count'] = qs.filter(events__eventtype=3).count()

        context['months'] = make_discrete_bar_chart(
            'months', get_users_statistics_months(app_id=app.id))
        context['weeks'] = make_discrete_bar_chart(
            'weeks', get_users_statistics_weeks(app_id=app.id))
        context['versions'] = make_piechart('versions',
                                            get_users_versions(app.id))
        context['channels'] = make_piechart('channels',
                                            get_channel_statistics(app.id))

        return context
Пример #5
0
    def get_context_data(self, **kwargs):
        context = super(MonitoringFormView, self).get_context_data(**kwargs)
        omaha_version_size = float(cache.get('omaha_version_size')
                                   or 0) / 1073741824
        sparkle_version_size = float(cache.get('sparkle_version_size')
                                     or 0) / 1073741824
        feedbacks_size = float(cache.get('feedbacks_size') or 0) / 1073741824
        crashes_size = float(cache.get('crashes_size') or 0) / 1073741824
        symbols_size = float(cache.get('symbols_size') or 0) / 1073741824

        data = dict(
            omaha_version=dict(label='Omaha Versions',
                               size=omaha_version_size,
                               limit=gpm['Version__limit_size'],
                               percent=omaha_version_size /
                               gpm['Version__limit_size'] * 100),
            sparkle_version=dict(label='Sparkle Versions',
                                 size=sparkle_version_size,
                                 limit=gpm['SparkleVersion__limit_size'],
                                 percent=sparkle_version_size /
                                 gpm['SparkleVersion__limit_size'] * 100),
            feedbacks=dict(label='Feedbacks',
                           size=feedbacks_size,
                           limit=gpm['Feedback__limit_size'],
                           percent=feedbacks_size /
                           gpm['Feedback__limit_size'] * 100),
            crashes=dict(label='Crashes',
                         size=crashes_size,
                         limit=gpm['Crash__limit_size'],
                         percent=crashes_size / gpm['Crash__limit_size'] *
                         100),
            symbols=dict(label='Symbols',
                         size=symbols_size,
                         limit=gpm['Symbols__limit_size'],
                         percent=symbols_size / gpm['Symbols__limit_size'] *
                         100),
        )
        full_size = reduce(lambda res, x: res + x['size'], list(data.values()),
                           0)
        context.update(data)
        piechart = None
        if full_size:
            pie_data = [(x['label'], x['size'] / full_size * 100)
                        for x in list(data.values())]
            piechart = make_piechart('used_space', pie_data, unit="%")
        context.update({'used_space': piechart})
        return context
Пример #6
0
 def test_make_piechart(self):
     data = [('apple', 10), ('orange', 3)]
     self.assertDictEqual(
         make_piechart('test', data), {
             'chartcontainer': 'chart_container_test',
             'chartdata': {
                 'extra1': {
                     'tooltip': {
                         'y_end': ' users',
                         'y_start': ''
                     }
                 },
                 'x': ['apple', 'orange'],
                 'y1': [10, 3]
             },
             'charttype': 'pieChart',
             'extra': {
                 'jquery_on_ready': False,
                 'tag_script_js': True,
                 'x_axis_format': '',
                 'x_is_date': False
             }
         })
Пример #7
0
    def get_context_data(self, **kwargs):
        context = super(MonitoringFormView, self).get_context_data(**kwargs)
        omaha_version_size = float(cache.get('omaha_version_size') or 0)/1073741824
        sparkle_version_size = float(cache.get('sparkle_version_size') or 0)/1073741824
        feedbacks_size = float(cache.get('feedbacks_size') or 0)/1073741824
        crashes_size = float(cache.get('crashes_size') or 0)/1073741824
        symbols_size = float(cache.get('symbols_size') or 0)/1073741824

        data = dict(
            omaha_version=dict(label='Omaha Versions', size=omaha_version_size, limit=gpm['Version__limit_size'], percent=omaha_version_size/gpm['Version__limit_size']*100),
            sparkle_version=dict(label='Sparkle Versions', size=sparkle_version_size, limit=gpm['SparkleVersion__limit_size'], percent=sparkle_version_size/gpm['SparkleVersion__limit_size']*100),
            feedbacks=dict(label='Feedbacks', size=feedbacks_size, limit=gpm['Feedback__limit_size'], percent=feedbacks_size/gpm['Feedback__limit_size']*100),
            crashes=dict(label='Crashes',  size=crashes_size, limit=gpm['Crash__limit_size'], percent=crashes_size/gpm['Crash__limit_size']*100),
            symbols=dict(label='Symbols',  size=symbols_size, limit=gpm['Symbols__limit_size'], percent=symbols_size/gpm['Symbols__limit_size']*100),
        )
        full_size = reduce(lambda res, x: res + x['size'], data.values(), 0)
        context.update(data)
        piechart = None
        if full_size:
            pie_data = [(x['label'], x['size']/full_size * 100) for x in data.values()]
            piechart = make_piechart('used_space', pie_data, unit="%")
        context.update({'used_space': piechart})
        return context