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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)