Code Duplication    Length = 12-13 lines in 4 locations

reports/spacesaving.py 1 location

@@ 770-781 (lines=12) @@
767
        result['child_space']['subtotals_saving'] = list()
768
        result['child_space']['subtotals_in_kgce_saving'] = list()
769
        result['child_space']['subtotals_in_kgco2e_saving'] = list()
770
        if energy_category_set is not None and len(energy_category_set) > 0:
771
            for energy_category_id in energy_category_set:
772
                result['child_space']['energy_category_names'].append(energy_category_dict[energy_category_id]['name'])
773
                result['child_space']['units'].append(energy_category_dict[energy_category_id]['unit_of_measure'])
774
                result['child_space']['child_space_names_array'].append(
775
                    child_space_data[energy_category_id]['child_space_names'])
776
                result['child_space']['subtotals_saving'].append(
777
                    child_space_data[energy_category_id]['subtotal_saving'])
778
                result['child_space']['subtotals_in_kgce_saving'].append(
779
                    child_space_data[energy_category_id]['subtotal_in_kgce_saving'])
780
                result['child_space']['subtotals_in_kgco2e_saving'].append(
781
                    child_space_data[energy_category_id]['subtotal_in_kgco2e_saving'])
782
783
        resp.body = json.dumps(result)
784

reports/spaceenergycategory.py 1 location

@@ 623-634 (lines=12) @@
620
        result['child_space']['subtotals'] = list()
621
        result['child_space']['subtotals_in_kgce'] = list()
622
        result['child_space']['subtotals_in_kgco2e'] = list()
623
        if energy_category_set is not None and len(energy_category_set) > 0:
624
            for energy_category_id in energy_category_set:
625
                result['child_space']['energy_category_names'].append(energy_category_dict[energy_category_id]['name'])
626
                result['child_space']['units'].append(energy_category_dict[energy_category_id]['unit_of_measure'])
627
                result['child_space']['child_space_names_array'].append(
628
                    child_space_data[energy_category_id]['child_space_names'])
629
                result['child_space']['subtotals'].append(
630
                    child_space_data[energy_category_id]['subtotal'])
631
                result['child_space']['subtotals_in_kgce'].append(
632
                    child_space_data[energy_category_id]['subtotal_in_kgce'])
633
                result['child_space']['subtotals_in_kgco2e'].append(
634
                    child_space_data[energy_category_id]['subtotal_in_kgco2e'])
635
636
        resp.body = json.dumps(result)
637

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'] = list()
915
        result['child_space_input']['subtotals_in_kgce'] = list()
916
        result['child_space_input']['subtotals_in_kgco2e'] = list()
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(energy_category_dict[energy_category_id]['name'])
920
                result['child_space_input']['units'].append(energy_category_dict[energy_category_id]['unit_of_measure'])
921
                result['child_space_input']['child_space_names_array'].append(
922
                    child_space_input[energy_category_id]['child_space_names'])
923
                result['child_space_input']['subtotals'].append(
924
                    child_space_input[energy_category_id]['subtotal'])
925
                result['child_space_input']['subtotals_in_kgce'].append(
926
                    child_space_input[energy_category_id]['subtotal_in_kgce'])
927
                result['child_space_input']['subtotals_in_kgco2e'].append(
928
                    child_space_input[energy_category_id]['subtotal_in_kgco2e'])
929
930
        result['child_space_cost'] = dict()
931
        result['child_space_cost']['energy_category_names'] = list()