Code Duplication    Length = 15-29 lines in 2 locations

pyfreebilling/pyfreebill/views.py 1 location

@@ 603-631 (lines=29) @@
600
    return {'companies': company_list}
601
602
603
@user_passes_test(lambda u: u.is_superuser)
604
@staff_member_required
605
def admin_report_view(request):
606
    # view code
607
    qs_d = DimCustomerDestination.objects.all()
608
    qs_h = DimCustomerHangupcause.objects.all()
609
610
#    qss_total_calls = qsstats.QuerySetStats(qs, 'date__date', aggregate=Sum('total_calls'))
611
#    qss_success_calls = qsstats.QuerySetStats(qs, 'date__date', aggregate=Sum('success_calls'))
612
#    qss_total_duration = qsstats.QuerySetStats(qs, 'date__date', aggregate=Sum('total_duration'))
613
#    qss_total_sell = qsstats.QuerySetStats(qs, 'date__date', aggregate=Sum('total_sell'))
614
#    qss_total_cost = qsstats.QuerySetStats(qs, 'date__date', aggregate=Sum('total_cost'))
615
616
    today = datetime.date.today()
617
    firstday = today - datetime.timedelta(days=7)
618
619
    ts_total_calls = time_series(
620
        qs_h, 'date__date', [firstday, today], func=Sum('total_calls'))
621
    ts_success_calls = time_series(
622
        qs_d, 'date__date', [firstday, today], func=Sum('success_calls'))
623
    ts_total_duration = time_series(
624
        qs_d, 'date__date', [firstday, today], func=Sum('total_duration'))
625
    ts_total_sell = time_series(
626
        qs_d, 'date__date', [firstday, today], func=Sum('total_sell'))
627
    ts_total_cost = time_series(
628
        qs_d, 'date__date', [firstday, today], func=Sum('total_cost'))
629
    ts_total_margin = _margin_series(ts_total_sell, ts_total_cost)
630
631
    return render(request, 'admin/admin_report.html', locals())
632

pyfreebilling/pyfreebill/templatetags/dashboard_tags.py 1 location

@@ 33-47 (lines=15) @@
30
    return {'companies' : company_list}
31
32
33
@register.inclusion_tag('snippets/dashboard.html')
34
def total_stats():
35
    qs_d = DimCustomerDestination.objects.all()
36
    qs_h = DimCustomerHangupcause.objects.all()
37
38
39
    today = datetime.date.today()
40
    firstday = today - datetime.timedelta(days=30)
41
42
    ts_total_calls = time_series(qs_h, 'date__date', [firstday, today], func=Sum('total_calls'))
43
    ts_success_calls = time_series(qs_d, 'date__date', [firstday, today], func=Sum('success_calls'))
44
    ts_total_duration = time_series(qs_d, 'date__date', [firstday, today], func=Sum('total_duration'))
45
    ts_total_sell = time_series(qs_d, 'date__date', [firstday, today], func=Sum('total_sell'))
46
    ts_total_cost = time_series(qs_d, 'date__date', [firstday, today], func=Sum('total_cost'))
47
    return locals()
48
49
50
def get_num_user_orders(parser, token):