Code Duplication    Length = 12-14 lines in 2 locations

myems-api/reports/energystoragepowerstationlist.py 1 location

@@ 299-312 (lines=14) @@
296
                # get battery soc point, power point
297
                battery_soc_point_value = None
298
                battery_power_point_value = None
299
                if is_online:
300
                    query = (" SELECT tescb.soc_point_id, tescb.power_point_id "
301
                             " FROM tbl_energy_storage_power_stations_containers tespsc, "
302
                             "      tbl_energy_storage_containers_batteries tescb "
303
                             " WHERE tespsc.energy_storage_power_station_id = %s "
304
                             "       AND tespsc.energy_storage_container_id = tescb.energy_storage_container_id "
305
                             " LIMIT 1 ")
306
                    cursor_system_db.execute(query, (energy_storage_power_station_id,))
307
                    row_point = cursor_system_db.fetchone()
308
                    if row_point is not None and len(row_point) > 0:
309
                        if analog_value_latest_dict.get(row_point[0]) is not None:
310
                            battery_soc_point_value = analog_value_latest_dict.get(row_point[0])['actual_value']
311
                        if analog_value_latest_dict.get(row_point[1]) is not None:
312
                            battery_power_point_value = analog_value_latest_dict.get(row_point[1])['actual_value']
313
314
                # complete the charge_report_dict
315
                if energy_storage_power_station_id not in charge_report_dict.keys():

myems-api/reports/microgridlist.py 1 location

@@ 188-199 (lines=12) @@
185
                # get battery soc point, power point
186
                battery_soc_point_value = None
187
                battery_power_point_value = None
188
                if is_online:
189
                    query = (" SELECT soc_point_id, power_point_id "
190
                             " FROM tbl_microgrids_batteries "
191
                             " WHERE microgrid_id = %s "
192
                             " LIMIT 1 ")
193
                    cursor_system_db.execute(query, (microgrid_id, ))
194
                    row_point = cursor_system_db.fetchone()
195
                    if row_point is not None and len(row_point) > 0:
196
                        if analog_value_latest_dict.get(row_point[0]) is not None:
197
                            battery_soc_point_value = analog_value_latest_dict.get(row_point[0])['actual_value']
198
                        if analog_value_latest_dict.get(row_point[1]) is not None:
199
                            battery_power_point_value = analog_value_latest_dict.get(row_point[1])['actual_value']
200
201
                # get photovoltaic power point
202
                photovoltaic_power_point_value = None