diff --git a/code/pep-stats-report/app/db_helper.py b/code/pep-stats-report/app/db_helper.py index 64d2bc0..43aa29b 100644 --- a/code/pep-stats-report/app/db_helper.py +++ b/code/pep-stats-report/app/db_helper.py @@ -181,4 +181,5 @@ SELECT user_name, ROUND(AVG(procinst_duration_in_minutes) /60, 2) as procinst_duration_in_hours_by_user from ({}) as r2 group by r2.user_name +order by procinst_duration_in_hours_by_user DESC """.format(querystring_user_procinst_duration(start, end, True, department)) diff --git a/code/pep-stats-report/main.py b/code/pep-stats-report/main.py index 1bb5be6..620839d 100644 --- a/code/pep-stats-report/main.py +++ b/code/pep-stats-report/main.py @@ -165,9 +165,13 @@ def add_chapter_2(doc): departments_excluded = ['汇派-质量部', '汇派-生产部', '汇派-计划部', '汇派-人事部', '汇派-采购部', '党建工会', '工程项目中心', '北京技术中心'] - for index, (department, elapse) in enumerate(procinst_duration_by_department): + d = [] + for department, elapse in procinst_duration_by_department: if department not in departments_excluded: - add_section(doc, index + 1, department, elapse) + d.append((department, elapse)) + + for index, (department, elapse) in enumerate(d): + add_section(doc, index + 1, department, elapse) def add_chapter_1(doc):