Code Duplication    Length = 15-15 lines in 2 locations

clean_energy_value.py 2 locations

@@ 439-453 (lines=15) @@
436
                continue
437
438
        print('bad list: ' + str(bad_list))
439
        if len(bad_list) > 0:
440
            try:
441
                update = (" UPDATE tbl_energy_value "
442
                          " SET is_bad = TRUE "
443
                          " WHERE id IN (" + ', '.join(map(str, bad_list)) + ")")
444
                cursor.execute(update, )
445
                cnx.commit()
446
            except Exception as e:
447
                logger.error("Error in step 3.2 of clean_energy_value.process " + str(e))
448
                if cursor:
449
                    cursor.close()
450
                if cnx:
451
                    cnx.close()
452
                time.sleep(60)
453
                continue
454
455
        ################################################################################################################
456
        # TODO: bad case 2.8
@@ 224-238 (lines=15) @@
221
                    bad_list.append(row_energy_value[0])
222
223
        print('bad list: ' + str(bad_list))
224
        if len(bad_list) > 0:
225
            try:
226
                update = (" UPDATE tbl_energy_value "
227
                          " SET is_bad = TRUE "
228
                          " WHERE id IN (" + ', '.join(map(str, bad_list)) + ")")
229
                cursor.execute(update, )
230
                cnx.commit()
231
            except Exception as e:
232
                logger.error("Error in step 2.3 of clean_energy_value.process " + str(e))
233
                if cursor:
234
                    cursor.close()
235
                if cnx:
236
                    cnx.close()
237
                time.sleep(60)
238
                continue
239
240
        ################################################################################################################
241
        # Step 3: check bad case class 2 which is in concave shape model.