예제 #1
0
파일: views.py 프로젝트: rtnpro/zamboni
def finance_line_series(request, addon, group, start, end, format, primary_field=None, inapp=None):
    """
    Date-based contribution series.
    primary_field -- revenue/count/refunds
    inapp -- inapp name, which shows stats for a certain inapp
    """
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon, for_contributions=True)

    if inapp:
        series = get_series_line(
            InappPayment,
            group,
            primary_field=primary_field,
            addon=addon.id,
            date__range=date_range,
            inapp=inapp.lower(),
        )
    else:
        series = get_series_line(
            Contribution, group, primary_field=primary_field, addon=addon.id, date__range=date_range
        )

    if format == "csv":
        return render_csv(request, addon, series, ["date", "count"])
    elif format == "json":
        return render_json(request, addon, series)
예제 #2
0
파일: views.py 프로젝트: KryDos/zamboni
def finance_column_series(request, addon, group, start, end, format,
                          primary_field=None, category_field=None,
                          inapp=None):
    """
    Non-date-based contribution series, column graph.
    primary_field -- revenue/count/refunds
    category_field -- breakdown field, currency/source
    inapp -- inapp name, which shows stats for a certain inapp
    """
    check_stats_permission(request, addon, for_contributions=True)

    if not inapp:
        series = get_series_column(Contribution, primary_field=primary_field,
            category_field=category_field, addon=addon.id)
    else:
        series = get_series_column(InappPayment, primary_field=primary_field,
            category_field=category_field, config__addon=addon.id,
            name=inapp.lower())

    # Since we're currently storing everything in lower-case in ES,
    # re-capitalize the currency.
    if category_field == 'currency':
        series = list(series)
        for datum in series:
            datum['currency'] = datum['currency'].upper()

    if format == 'csv':
        return render_csv(request, addon, series, [category_field, 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #3
0
def my_apps_series(request, group, start, end, format):
    """
    Install counts for multiple apps. This is a temporary hack that will
    probably live forever.
    """
    date_range = check_series_params_or_404(group, start, end, format)
    apps = _my_apps(request)
    series = []
    for app in apps:
        # The app name is going to appended in slightly different ways
        # depending upon data format.
        if format == 'csv':
            series = get_series_line(Installed,
                                     group,
                                     addon=app.id,
                                     date__range=date_range,
                                     extra_values={'name': (app.name)})
        elif format == 'json':
            data = get_series_line(Installed,
                                   group,
                                   addon=app.id,
                                   date__range=date_range)
            series.append({'name': str(app.name), 'data': list(data)})

    if format == 'csv':
        return render_csv(request, apps, series, ['name', 'date', 'count'])
    elif format == 'json':
        return render_json(request, apps, series)
예제 #4
0
def finance_line_series(request,
                        addon,
                        group,
                        start,
                        end,
                        format,
                        primary_field=None,
                        inapp=None):
    """
    Date-based contribution series.
    primary_field -- revenue/count/refunds
    inapp -- inapp name, which shows stats for a certain inapp
    """
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon, for_contributions=True)

    if inapp:
        series = get_series_line(InappPayment,
                                 group,
                                 primary_field=primary_field,
                                 addon=addon.id,
                                 date__range=date_range,
                                 inapp=inapp.lower())
    else:
        series = get_series_line(Contribution,
                                 group,
                                 primary_field=primary_field,
                                 addon=addon.id,
                                 date__range=date_range)

    if format == 'csv':
        return render_csv(request, addon, series, ['date', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #5
0
파일: views.py 프로젝트: at13/zamboni
def finance_column_series(request, addon, group, start, end, format,
                          primary_field=None, category_field=None,
                          inapp=None):
    """
    Non-date-based contribution series, column graph.
    primary_field -- revenue/count/refunds
    category_field -- breakdown field, currency/source
    inapp -- inapp name, which shows stats for a certain inapp
    """
    check_stats_permission(request, addon, for_contributions=True)

    if not inapp:
        series = get_series_column(Contribution, primary_field=primary_field,
            category_field=category_field, addon=addon.id)
    else:
        series = get_series_column(InappPayment, primary_field=primary_field,
            category_field=category_field, config__addon=addon.id,
            name=inapp.lower())

    # Since we're currently storing everything in lower-case in ES,
    # re-capitalize the currency.
    if category_field == 'currency':
        series = list(series)
        for datum in series:
            datum['currency'] = datum['currency'].upper()

    if format == 'csv':
        return render_csv(request, addon, series, [category_field, 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #6
0
def usage_series(request, addon, group, start, end, format):
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon)

    series = get_series_line(UpdateCount, group, addon=addon.id, date__range=date_range)

    if format == "csv":
        return render_csv(request, addon, series, ["date", "count"])
    elif format == "json":
        return render_json(request, addon, series)
예제 #7
0
파일: views.py 프로젝트: gkoberger/zamboni
def usage_series(request, addon, group, start, end, format):
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon)

    series = get_series(UpdateCount, addon=addon.id, date__range=date_range)

    if format == 'csv':
        return render_csv(request, addon, series, ['date', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #8
0
파일: views.py 프로젝트: gkoberger/zamboni
def overview_series(request, addon, group, start, end, format):
    """Combines installs_series and usage_series into one payload."""
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon)

    return fake_app_stats(request, addon, group, start, end, format)

    series = get_series(Installed, addon=addon.id, date__range=date_range)

    return render_json(request, addon, series)
예제 #9
0
def refunds_series(request, addon, group, start, end, format):
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon, for_contributions=True)

    series = get_series(Contribution, group, primary_field="refunds", addon=addon.id, date__range=date_range)

    if format == "csv":
        return render_csv(request, addon, series, ["date", "count"])
    elif format == "json":
        return render_json(request, addon, series)
예제 #10
0
def installs_series(request, addon, group, start, end, format):
    """Generate install counts grouped by ``group`` in ``format``."""
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon)
    series = get_series(Installed, addon=addon.id, date__range=date_range)

    if format == 'csv':
        return render_csv(request, addon, series, ['date', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #11
0
def refunds_series(request, addon, group, start, end, format):
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon, for_contributions=True)

    series = get_series(Contribution, group, primary_field='refunds',
        addon=addon.id, date__range=date_range)

    if format == 'csv':
        return render_csv(request, addon, series, ['date', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #12
0
def overview_series(request, addon, group, start, end, format):
    """Combines installs_series and usage_series into one payload."""
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon)

    series = get_series(Installed, group, addon=addon.id, date__range=date_range)

    if format == "csv":
        return render_csv(request, addon, series, ["date", "count"])
    elif format == "json":
        return render_json(request, addon, series)
예제 #13
0
파일: views.py 프로젝트: icaaq/zamboni
def refunds_series(request, addon, group, start, end, format):
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon, for_contributions=True)

    series = get_series(Contribution, group, primary_field='refunds',
        addon=addon.id, date__range=date_range)

    if format == 'csv':
        return render_csv(request, addon, series, ['date', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #14
0
def overview_series(request, addon, group, start, end, format):
    """Combines installs_series and usage_series into one payload."""
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon)

    dls = get_series(DownloadCount, addon=addon.id, date__range=date_range)

    # Uncomment the line below to return fake stats.
    return fake_app_stats(request, addon, group, start, end, format)

    return render_json(request, addon, dls)
예제 #15
0
파일: views.py 프로젝트: gedex/zamboni
def source_series(request, addon, group, start, end, format,
                  primary_field=None):
    check_stats_permission(request, addon, for_contributions=True)

    series = get_series_column(Contribution, primary_field=primary_field,
                               category_field='source', addon=addon.id)

    if format == 'csv':
        return render_csv(request, addon, series, ['source', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #16
0
파일: views.py 프로젝트: at13/zamboni
def usage_series(request, addon, group, start, end, format):
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon)

    series = get_series_line(UpdateCount, group, addon=addon.id,
                             date__range=date_range)

    if format == 'csv':
        return render_csv(request, addon, series, ['date', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #17
0
def installs_series(request, addon, group, start, end, format):
    """Generate install counts grouped by ``group`` in ``format``."""
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon)

    series = get_series(Installed, group, addon=addon.id,
                        date__range=date_range)

    if format == 'csv':
        return render_csv(request, addon, series, ['date', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #18
0
def overview_series(request, addon, group, start, end, format):
    """Combines installs_series and usage_series into one payload."""
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon)

    series = get_series(Installed, group, addon=addon.id,
                        date__range=date_range)

    if format == 'csv':
        return render_csv(request, addon, series, ['date', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #19
0
def usage_series(request, addon, group, start, end, format):
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon)

    series = get_series(DownloadCount, addon=addon.id, date__range=date_range)

    # Uncomment the line below to return fake stats.
    return fake_app_stats(request, addon, group, start, end, format)

    if format == 'csv':
        return render_csv(request, addon, series, ['date', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #20
0
파일: views.py 프로젝트: gkoberger/zamboni
def sales_series(request, addon, group, start, end, format):
    """
    Sequel to contribution series
    """
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon, for_contributions=True)

    series = get_series(Contribution, addon=addon.id, date__range=date_range)

    if format == 'csv':
        return render_csv(request, addon, series, ['date', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #21
0
def finance_line_series(request, addon, group, start, end, format, primary_field=None):
    """
    Date-based contribution series.
    primary_field -- revenue/count/refunds
    """
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon, for_contributions=True)

    series = get_series_line(Contribution, group, primary_field=primary_field, addon=addon.id, date__range=date_range)

    if format == "csv":
        return render_csv(request, addon, series, ["date", "count"])
    elif format == "json":
        return render_json(request, addon, series)
예제 #22
0
def sales_series(request, addon, group, start, end, format):
    """
    Sequel to contribution series
    """
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon, for_contributions=True)

    series = get_series(Contribution, group, addon=addon.id,
                        date__range=date_range)

    if format == 'csv':
        return render_csv(request, addon, series, ['date', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #23
0
파일: views.py 프로젝트: gedex/zamboni
def currency_series(request, addon, group, start, end, format,
                    primary_field=None):
    check_stats_permission(request, addon, for_contributions=True)

    series = get_series_column(Contribution, primary_field=primary_field,
                               category_field='currency', addon=addon.id)

    # Since we're currently storing everything in lower-case in ES,
    # re-capitalize the currency.
    series = list(series)
    for datum in series:
        datum['currency'] = datum['currency'].upper()

    if format == 'csv':
        return render_csv(request, addon, series, ['currency', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #24
0
파일: views.py 프로젝트: marco-c/zamboni
def source_series(request,
                  addon,
                  group,
                  start,
                  end,
                  format,
                  primary_field=None):
    check_stats_permission(request, addon, for_contributions=True)

    series = get_series_column(Contribution,
                               primary_field=primary_field,
                               category_field='source',
                               addon=addon.id)

    if format == 'csv':
        return render_csv(request, addon, series, ['source', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #25
0
def finance_column_series(request, addon, group, start, end, format, primary_field=None, category_field=None):
    """
    Non-date-based contribution series, column graph.
    primary_field -- revenue/count/refunds
    category_field -- breakdown field, currency/source
    """
    check_stats_permission(request, addon, for_contributions=True)

    series = get_series_column(Contribution, primary_field=primary_field, category_field=category_field, addon=addon.id)

    # Since we're currently storing everything in lower-case in ES,
    # re-capitalize the currency.
    if category_field == "currency":
        series = list(series)
        for datum in series:
            datum["currency"] = datum["currency"].upper()

    if format == "csv":
        return render_csv(request, addon, series, [category_field, "count"])
    elif format == "json":
        return render_json(request, addon, series)
예제 #26
0
def my_apps_series(request, group, start, end, format):
    """
    Install counts for multiple apps. This is a temporary hack that will
    probably live forever.
    """
    date_range = check_series_params_or_404(group, start, end, format)
    apps = _my_apps(request)
    series = []
    for app in apps:
        # The app name is going to appended in slightly different ways
        # depending upon data format.
        if format == "csv":
            series = get_series_line(
                Installed, group, addon=app.id, date__range=date_range, extra_values={"name": (app.name)}
            )
        elif format == "json":
            data = get_series_line(Installed, group, addon=app.id, date__range=date_range)
            series.append({"name": str(app.name), "data": list(data)})

    if format == "csv":
        return render_csv(request, apps, series, ["name", "date", "count"])
    elif format == "json":
        return render_json(request, apps, series)
예제 #27
0
파일: views.py 프로젝트: sunbiz/zamboni
def finance_line_series(request,
                        addon,
                        group,
                        start,
                        end,
                        format,
                        primary_field=None):
    """
    Date-based contribution series.
    primary_field -- revenue/count/refunds
    """
    date_range = check_series_params_or_404(group, start, end, format)
    check_stats_permission(request, addon, for_contributions=True)

    series = get_series_line(Contribution,
                             group,
                             primary_field=primary_field,
                             addon=addon.id,
                             date__range=date_range)

    if format == 'csv':
        return render_csv(request, addon, series, ['date', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)
예제 #28
0
파일: views.py 프로젝트: marco-c/zamboni
def currency_series(request,
                    addon,
                    group,
                    start,
                    end,
                    format,
                    primary_field=None):
    check_stats_permission(request, addon, for_contributions=True)

    series = get_series_column(Contribution,
                               primary_field=primary_field,
                               category_field='currency',
                               addon=addon.id)

    # Since we're currently storing everything in lower-case in ES,
    # re-capitalize the currency.
    series = list(series)
    for datum in series:
        datum['currency'] = datum['currency'].upper()

    if format == 'csv':
        return render_csv(request, addon, series, ['currency', 'count'])
    elif format == 'json':
        return render_json(request, addon, series)