Code Duplication    Length = 24-24 lines in 2 locations

reports/spaceenergycategory.py 1 location

@@ 569-592 (lines=24) @@
566
        result['reporting_period']['increment_rate_in_kgce'] = Decimal(0.0)
567
        result['reporting_period']['increment_rate_in_kgco2e'] = Decimal(0.0)
568
569
        if energy_category_set is not None and len(energy_category_set) > 0:
570
            for energy_category_id in energy_category_set:
571
                result['reporting_period']['names'].append(energy_category_dict[energy_category_id]['name'])
572
                result['reporting_period']['energy_category_ids'].append(energy_category_id)
573
                result['reporting_period']['units'].append(energy_category_dict[energy_category_id]['unit_of_measure'])
574
                result['reporting_period']['timestamps'].append(reporting[energy_category_id]['timestamps'])
575
                result['reporting_period']['values'].append(reporting[energy_category_id]['values'])
576
                result['reporting_period']['subtotals'].append(reporting[energy_category_id]['subtotal'])
577
                result['reporting_period']['subtotals_in_kgce'].append(
578
                    reporting[energy_category_id]['subtotal_in_kgce'])
579
                result['reporting_period']['subtotals_in_kgco2e'].append(
580
                    reporting[energy_category_id]['subtotal_in_kgco2e'])
581
                result['reporting_period']['subtotals_per_unit_area'].append(
582
                    reporting[energy_category_id]['subtotal'] / space['area'] if space['area'] > 0.0 else None)
583
                result['reporting_period']['toppeaks'].append(reporting[energy_category_id]['toppeak'])
584
                result['reporting_period']['onpeaks'].append(reporting[energy_category_id]['onpeak'])
585
                result['reporting_period']['midpeaks'].append(reporting[energy_category_id]['midpeak'])
586
                result['reporting_period']['offpeaks'].append(reporting[energy_category_id]['offpeak'])
587
                result['reporting_period']['increment_rates'].append(
588
                    (reporting[energy_category_id]['subtotal'] - base[energy_category_id]['subtotal']) /
589
                    base[energy_category_id]['subtotal']
590
                    if base[energy_category_id]['subtotal'] > 0.0 else None)
591
                result['reporting_period']['total_in_kgce'] += reporting[energy_category_id]['subtotal_in_kgce']
592
                result['reporting_period']['total_in_kgco2e'] += reporting[energy_category_id]['subtotal_in_kgco2e']
593
594
        result['reporting_period']['total_in_kgco2e_per_unit_area'] = \
595
            result['reporting_period']['total_in_kgce'] / space['area'] if space['area'] > 0.0 else None

reports/tenantenergycategory.py 1 location

@@ 519-542 (lines=24) @@
516
        result['reporting_period']['increment_rate_in_kgce'] = Decimal(0.0)
517
        result['reporting_period']['increment_rate_in_kgco2e'] = Decimal(0.0)
518
519
        if energy_category_set is not None and len(energy_category_set) > 0:
520
            for energy_category_id in energy_category_set:
521
                result['reporting_period']['names'].append(energy_category_dict[energy_category_id]['name'])
522
                result['reporting_period']['energy_category_ids'].append(energy_category_id)
523
                result['reporting_period']['units'].append(energy_category_dict[energy_category_id]['unit_of_measure'])
524
                result['reporting_period']['timestamps'].append(reporting[energy_category_id]['timestamps'])
525
                result['reporting_period']['values'].append(reporting[energy_category_id]['values'])
526
                result['reporting_period']['subtotals'].append(reporting[energy_category_id]['subtotal'])
527
                result['reporting_period']['subtotals_in_kgce'].append(
528
                    reporting[energy_category_id]['subtotal_in_kgce'])
529
                result['reporting_period']['subtotals_in_kgco2e'].append(
530
                    reporting[energy_category_id]['subtotal_in_kgco2e'])
531
                result['reporting_period']['subtotals_per_unit_area'].append(
532
                    reporting[energy_category_id]['subtotal'] / tenant['area'] if tenant['area'] > 0.0 else None)
533
                result['reporting_period']['toppeaks'].append(reporting[energy_category_id]['toppeak'])
534
                result['reporting_period']['onpeaks'].append(reporting[energy_category_id]['onpeak'])
535
                result['reporting_period']['midpeaks'].append(reporting[energy_category_id]['midpeak'])
536
                result['reporting_period']['offpeaks'].append(reporting[energy_category_id]['offpeak'])
537
                result['reporting_period']['increment_rates'].append(
538
                    (reporting[energy_category_id]['subtotal'] - base[energy_category_id]['subtotal']) /
539
                    base[energy_category_id]['subtotal']
540
                    if base[energy_category_id]['subtotal'] > 0.0 else None)
541
                result['reporting_period']['total_in_kgce'] += reporting[energy_category_id]['subtotal_in_kgce']
542
                result['reporting_period']['total_in_kgco2e'] += reporting[energy_category_id]['subtotal_in_kgco2e']
543
544
        result['reporting_period']['total_in_kgco2e_per_unit_area'] = \
545
            result['reporting_period']['total_in_kgce'] / tenant['area'] if tenant['area'] > 0.0 else None