mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-22 07:53:19 +01:00
Add get_report_table_and_totals
helper function
Extracts a large portion of run_report handling
This commit is contained in:
parent
b1bf2cab46
commit
205c69b539
@ -1563,6 +1563,21 @@ def get_report_queryset_or_redirect(request, report):
|
|||||||
return report_queryset, query_params, saved_query, None
|
return report_queryset, query_params, saved_query, None
|
||||||
|
|
||||||
|
|
||||||
|
def get_report_table_and_totals(header1, summarytable, possible_options):
|
||||||
|
table = []
|
||||||
|
totals = {}
|
||||||
|
for item in header1:
|
||||||
|
data = []
|
||||||
|
for hdr in possible_options:
|
||||||
|
if hdr not in totals.keys():
|
||||||
|
totals[hdr] = summarytable[item, hdr]
|
||||||
|
else:
|
||||||
|
totals[hdr] += summarytable[item, hdr]
|
||||||
|
data.append(summarytable[item, hdr])
|
||||||
|
table.append([item] + data)
|
||||||
|
return table, totals
|
||||||
|
|
||||||
|
|
||||||
@helpdesk_staff_member_required
|
@helpdesk_staff_member_required
|
||||||
def run_report(request, report):
|
def run_report(request, report):
|
||||||
|
|
||||||
@ -1690,8 +1705,6 @@ def run_report(request, report):
|
|||||||
if report == 'daysuntilticketclosedbymonth':
|
if report == 'daysuntilticketclosedbymonth':
|
||||||
summarytable2[metric1, metric2] += metric3
|
summarytable2[metric1, metric2] += metric3
|
||||||
|
|
||||||
table = []
|
|
||||||
|
|
||||||
if report == 'daysuntilticketclosedbymonth':
|
if report == 'daysuntilticketclosedbymonth':
|
||||||
for key in summarytable2.keys():
|
for key in summarytable2.keys():
|
||||||
summarytable[key] = summarytable2[key] / summarytable[key]
|
summarytable[key] = summarytable2[key] / summarytable[key]
|
||||||
@ -1701,18 +1714,9 @@ def run_report(request, report):
|
|||||||
column_headings = [col1heading] + possible_options
|
column_headings = [col1heading] + possible_options
|
||||||
|
|
||||||
# Prepare a dict to store totals for each possible option
|
# Prepare a dict to store totals for each possible option
|
||||||
totals = {}
|
table, totals = get_report_table_and_totals(header1, summarytable, possible_options)
|
||||||
# Pivot the data so that 'header1' fields are always first column
|
# Pivot the data so that 'header1' fields are always first column
|
||||||
# in the row, and 'possible_options' are always the 2nd - nth columns.
|
# in the row, and 'possible_options' are always the 2nd - nth columns.
|
||||||
for item in header1:
|
|
||||||
data = []
|
|
||||||
for hdr in possible_options:
|
|
||||||
if hdr not in totals.keys():
|
|
||||||
totals[hdr] = summarytable[item, hdr]
|
|
||||||
else:
|
|
||||||
totals[hdr] += summarytable[item, hdr]
|
|
||||||
data.append(summarytable[item, hdr])
|
|
||||||
table.append([item] + data)
|
|
||||||
|
|
||||||
# Zip data and headers together in one list for Morris.js charts
|
# Zip data and headers together in one list for Morris.js charts
|
||||||
# will get a list like [(Header1, Data1), (Header2, Data2)...]
|
# will get a list like [(Header1, Data1), (Header2, Data2)...]
|
||||||
|
Loading…
Reference in New Issue
Block a user