From 82f268737a72a233ba5280abbbfdf0c5a9f0d0cc Mon Sep 17 00:00:00 2001 From: daovietanh99 Date: Fri, 16 Feb 2024 08:41:33 +0700 Subject: [PATCH 1/2] FIX: fix ui bugs --- cope2n-api/fwd_api/utils/file.py | 26 +++++++++----------------- cope2n-api/report.xlsx | Bin 6954 -> 6968 bytes 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/cope2n-api/fwd_api/utils/file.py b/cope2n-api/fwd_api/utils/file.py index c5094fb..9b596f8 100644 --- a/cope2n-api/fwd_api/utils/file.py +++ b/cope2n-api/fwd_api/utils/file.py @@ -490,37 +490,29 @@ def dict2xlsx(input: json, _type='report'): start_index = 4 for subtotal in input: - for key_index, key in enumerate(mapping.keys()): + for key in mapping.keys(): value = get_value(subtotal, mapping[key]) ws[key + str(start_index)] = value ws[key + str(start_index)].border = border if _type == 'report': + if key in ['J', 'L', 'M', 'N', 'O', 'P', 'Q']: + ws[key + str(start_index)].number_format = '0.0' if subtotal['subs'] == '+': ws[key + str(start_index)].font = font_black_bold - if key_index in [6, 8, 9, 10, 11, 12, 13]: - ws[key + str(start_index)].number_format = '0.0' - if key_index == 0 or (key_index >= 9 and key_index <= 15): + if key in ['A', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q']: ws[key + str(start_index)].fill = fill_gray - elif key_index == 1: + elif key == 'B': ws[key + str(start_index)].fill = fill_green - elif key_index >= 4 and key_index <= 8: + elif key in ['C', 'D', 'E', 'F', 'G', 'H']: ws[key + str(start_index)].fill = fill_yellow else: - if 'average_accuracy_rate' in mapping[key] and type(value) in [int, float]: - if value < 98: + if 'average_accuracy_rate' in mapping[key] and type(value) in [int, float] and value < 98: ws[key + str(start_index)].style = normal_cell_red - ws[key + str(start_index)].number_format = '0.0' - elif 'average_processing_time' in mapping[key] and type(value) in [int, float]: - if value > 2.0: + elif 'average_processing_time' in mapping[key] and type(value) in [int, float] and value > 2.0: ws[key + str(start_index)].style = normal_cell_red - ws[key + str(start_index)].number_format = '0.0' - elif 'bad_percent' in mapping[key] and type(value) in [int, float]: - if value > 10: + elif 'bad_percent' in mapping[key] and type(value) in [int, float] and value > 10: ws[key + str(start_index)].style = normal_cell_red - ws[key + str(start_index)].number_format = '0.0' - elif 'percent' in mapping[key] and type(value) in [int, float]: - ws[key + str(start_index)].number_format = '0.0' else : ws[key + str(start_index)].style = normal_cell elif _type == 'report_detail': diff --git a/cope2n-api/report.xlsx b/cope2n-api/report.xlsx index a7fa7e2ac06c6812f5f8a86c869885a2fce4a75e..49dc21e3c55f96605358ee5d5622857839f8d0cd 100644 GIT binary patch delta 3304 zcmZ{m2{hDg7r@61vV<7R*s>&RcCxGNjIonlh%t6jyoo=_k}b`MvXvzxjADkYDUBt& ztP@_5wX$n$;gk1#=dJIY?|II1?sM+_-Df%XoO^HS#oCJuW^f24D~N`M1_WU+t7H(O zfE-J_0>$}%HjZFf@QEgk()DD6*`gK)0t5uQ;-H4ZRfwC?*wRTOk=&Jc6cC$~l;lC- zgC7g;qA!p9?L0`nSVupQ7^VrxKW%q^U!fFPi7VNpO^OSw2^8sz7=3qPj?=ZZ)(A z{KnShw+6}kMyp!SCa>S#?4xDC3PIR(Tf{h0MMvmEtLq!W54>;E`;WNu8`^yJK47{- z9{7~aHJ6oSjBEGLQSwIy%iX2xJ#%0tJ;5_T-O#j@3V7xQaa!iU+4RzYf_n|KiY3z) z8%7aJ%KSRvnv!=1S17!D;ni^sf$e&1`(s71JPts5>3VISG`TM?YL$2UFiD)qYPolo z2AGXdG>Kpf&%QK~VK;7O%2YCQaCI3qb@?VDRD#ju6GDsIx!OsuI5VBKyhWdPicTs> zd>m`#G;rKC0|fbhYEQ zbw!BL?1%MTEsD3!`sy5~{ns8dGPeVLJyCUW$#1jJcsE`hVbU|`ybx3nH}6_p?_I|u zJ6HxwdW;zzvF`rw6m#=@r=lT-#NaLD)g%-LZ&*MzfJ#`v&R&Jf{HfLTffp~=$A9K; zj#CU1AQO8|^cREYGJAmSj*EkrKQW=PQ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7 From fe75bfd8be1499f1f80dc596a163396372242e7a Mon Sep 17 00:00:00 2001 From: daovietanh99 Date: Fri, 16 Feb 2024 09:02:57 +0700 Subject: [PATCH 2/2] UPDATE: reformatting code --- cope2n-api/fwd_api/utils/file.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/cope2n-api/fwd_api/utils/file.py b/cope2n-api/fwd_api/utils/file.py index 9b596f8..a256097 100644 --- a/cope2n-api/fwd_api/utils/file.py +++ b/cope2n-api/fwd_api/utils/file.py @@ -433,9 +433,7 @@ def dict2xlsx(input: json, _type='report'): border = Border(left=thin, right=thin, top=thin, bottom=thin) fill_green = PatternFill(start_color=green, end_color=green, fill_type = "solid") fill_yellow = PatternFill(start_color=yellow, end_color=yellow, fill_type = "solid") - fill_gray = PatternFill(start_color=gray, end_color=gray, fill_type = "solid") - normal_cell = NamedStyle(name="normal_cell", font=font_black, border=border) - normal_cell_red = NamedStyle(name="normal_cell_red", font=font_red, border=border) + fill_gray = PatternFill(start_color=gray, end_color=gray, fill_type = "solid") if _type == 'report': wb = load_workbook(filename = 'report.xlsx') @@ -494,10 +492,11 @@ def dict2xlsx(input: json, _type='report'): value = get_value(subtotal, mapping[key]) ws[key + str(start_index)] = value ws[key + str(start_index)].border = border + ws[key + str(start_index)].font = font_black + if 'accuracy' in mapping[key] or 'time' in mapping[key] or 'percent' in mapping[key] or 'speed' in mapping[key]: + ws[key + str(start_index)].number_format = '0.0' if _type == 'report': - if key in ['J', 'L', 'M', 'N', 'O', 'P', 'Q']: - ws[key + str(start_index)].number_format = '0.0' if subtotal['subs'] == '+': ws[key + str(start_index)].font = font_black_bold if key in ['A', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q']: @@ -506,25 +505,19 @@ def dict2xlsx(input: json, _type='report'): ws[key + str(start_index)].fill = fill_green elif key in ['C', 'D', 'E', 'F', 'G', 'H']: ws[key + str(start_index)].fill = fill_yellow - else: + else: if 'average_accuracy_rate' in mapping[key] and type(value) in [int, float] and value < 98: - ws[key + str(start_index)].style = normal_cell_red + ws[key + str(start_index)].font = font_red elif 'average_processing_time' in mapping[key] and type(value) in [int, float] and value > 2.0: - ws[key + str(start_index)].style = normal_cell_red + ws[key + str(start_index)].font = font_red elif 'bad_percent' in mapping[key] and type(value) in [int, float] and value > 10: - ws[key + str(start_index)].style = normal_cell_red - else : - ws[key + str(start_index)].style = normal_cell + ws[key + str(start_index)].font = font_red elif _type == 'report_detail': if 'accuracy' in mapping[key] and type(value) in [int, float] and value < 75: - ws[key + str(start_index)].number_format = '0.0' - ws[key + str(start_index)].style = normal_cell_red + ws[key + str(start_index)].font = font_red elif 'speed' in mapping[key] and type(value) in [int, float] and value > 2.0: - ws[key + str(start_index)].number_format = '0.0' - ws[key + str(start_index)].style = normal_cell_red - else: - ws[key + str(start_index)].style = normal_cell + ws[key + str(start_index)].font = font_red start_index += 1 - + return wb