Code Duplication    Length = 12-13 lines in 4 locations

reports/dashboard.py 2 locations

@@ 763-775 (lines=13) @@
760
        result['base_period_cost']['values'] = list()
761
        result['base_period_cost']['subtotals'] = list()
762
        result['base_period_cost']['total'] = Decimal(0.0)
763
        if energy_category_set is not None and len(energy_category_set) > 0:
764
            for energy_category_id in energy_category_set:
765
                result['base_period_cost']['names'].append(
766
                    energy_category_dict[energy_category_id]['name'])
767
                result['base_period_cost']['units'].append(
768
                    energy_category_dict[energy_category_id]['unit_of_measure'])
769
                result['base_period_cost']['timestamps'].append(
770
                    base_cost[energy_category_id]['timestamps'])
771
                result['base_period_cost']['values'].append(
772
                    base_cost[energy_category_id]['values'])
773
                result['base_period_cost']['subtotals'].append(
774
                    base_cost[energy_category_id]['subtotal'])
775
                result['base_period_cost']['total'] += base_cost[energy_category_id]['subtotal']
776
777
        result['reporting_period_input'] = dict()
778
        result['reporting_period_input']['names'] = list()
@@ 917-928 (lines=12) @@
914
        result['child_space_input']['subtotals_array'] = list()  # 2D array [energy category][child space]
915
        result['child_space_input']['subtotals_in_kgce_array'] = list()  # 2D array [energy category][child space]
916
        result['child_space_input']['subtotals_in_kgco2e_array'] = list()  # 2D array [energy category][child space]
917
        if energy_category_set is not None and len(energy_category_set) > 0:
918
            for energy_category_id in energy_category_set:
919
                result['child_space_input']['energy_category_names'].append(
920
                    energy_category_dict[energy_category_id]['name'])
921
                result['child_space_input']['units'].append(
922
                    energy_category_dict[energy_category_id]['unit_of_measure'])
923
                result['child_space_input']['child_space_names_array'].append(
924
                    child_space_input[energy_category_id]['child_space_names'])
925
                result['child_space_input']['subtotals_array'].append(
926
                    child_space_input[energy_category_id]['subtotals'])
927
                result['child_space_input']['subtotals_in_kgce_array'].append(
928
                    child_space_input[energy_category_id]['subtotals_in_kgce'])
929
                result['child_space_input']['subtotals_in_kgco2e_array'].append(
930
                    child_space_input[energy_category_id]['subtotals_in_kgco2e'])
931

reports/spaceenergycategory.py 1 location

@@ 624-635 (lines=12) @@
621
        result['child_space']['subtotals_array'] = list()  # 2D array [energy category][child space]
622
        result['child_space']['subtotals_in_kgce_array'] = list()  # 2D array [energy category][child space]
623
        result['child_space']['subtotals_in_kgco2e_array'] = list()  # 2D array [energy category][child space]
624
        if energy_category_set is not None and len(energy_category_set) > 0:
625
            for energy_category_id in energy_category_set:
626
                result['child_space']['energy_category_names'].append(energy_category_dict[energy_category_id]['name'])
627
                result['child_space']['units'].append(energy_category_dict[energy_category_id]['unit_of_measure'])
628
                result['child_space']['child_space_names_array'].append(
629
                    child_space_data[energy_category_id]['child_space_names'])
630
                result['child_space']['subtotals_array'].append(
631
                    child_space_data[energy_category_id]['subtotals'])
632
                result['child_space']['subtotals_in_kgce_array'].append(
633
                    child_space_data[energy_category_id]['subtotals_in_kgce'])
634
                result['child_space']['subtotals_in_kgco2e_array'].append(
635
                    child_space_data[energy_category_id]['subtotals_in_kgco2e'])
636
        # export result to Excel file and then encode the file to base64 string
637
        result['excel_bytes_base64'] = excelexporters.spaceenergycategory.export(result,
638
                                                                                 space['name'],

reports/spacesaving.py 1 location

@@ 762-773 (lines=12) @@
759
        result['child_space']['subtotals_saving_array'] = list()  # 2D array [energy category][child space]
760
        result['child_space']['subtotals_in_kgce_saving_array'] = list()  # 2D array [energy category][child space]
761
        result['child_space']['subtotals_in_kgco2e_saving_array'] = list()  # 2D array [energy category][child space]
762
        if energy_category_set is not None and len(energy_category_set) > 0:
763
            for energy_category_id in energy_category_set:
764
                result['child_space']['energy_category_names'].append(energy_category_dict[energy_category_id]['name'])
765
                result['child_space']['units'].append(energy_category_dict[energy_category_id]['unit_of_measure'])
766
                result['child_space']['child_space_names_array'].append(
767
                    child_space_data[energy_category_id]['child_space_names'])
768
                result['child_space']['subtotals_saving_array'].append(
769
                    child_space_data[energy_category_id]['subtotals_saving'])
770
                result['child_space']['subtotals_in_kgce_saving_array'].append(
771
                    child_space_data[energy_category_id]['subtotals_in_kgce_saving'])
772
                result['child_space']['subtotals_in_kgco2e_saving_array'].append(
773
                    child_space_data[energy_category_id]['subtotals_in_kgco2e_saving'])
774
775
        # export result to Excel file and then encode the file to base64 string
776
        result['excel_bytes_base64'] = excelexporters.spacesaving.export(result,