コード例 #1
0
def create_empty_monthly_notification_status_stats_dict(year):
    utc_month_starts = get_months_for_financial_year(year)
    # nested dicts - data[month][template type][status] = count
    return {
        convert_utc_to_bst(start).strftime('%Y-%m'):
        {template_type: defaultdict(int)
         for template_type in TEMPLATE_TYPES}
        for start in utc_month_starts
    }
コード例 #2
0
ファイル: rest.py プロジェクト: qld-gov-au/notify
def get_yearly_usage_by_month(service_id):
    try:
        year = int(request.args.get('year'))
        results = []
        for month in get_months_for_financial_year(year):
            billing_for_month = get_monthly_billing_by_notification_type(service_id, month, SMS_TYPE)
            if billing_for_month:
                results.append(_transform_billing_for_month_sms(billing_for_month))
            letter_billing_for_month = get_monthly_billing_by_notification_type(service_id, month, LETTER_TYPE)
            if letter_billing_for_month:
                results.extend(_transform_billing_for_month_letters(letter_billing_for_month))
        return json.dumps(results)

    except TypeError:
        return jsonify(result='error', message='No valid year provided'), 400