Code Duplication    Length = 11-11 lines in 6 locations

myems-api/core/shopfloor.py 3 locations

@@ 2296-2306 (lines=11) @@
2293
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
2294
                                   description='API.SHOPFLOOR_NAME_IS_ALREADY_IN_USE')
2295
2296
        if contact_id is not None:
2297
            cursor.execute(" SELECT name "
2298
                           " FROM tbl_contacts "
2299
                           " WHERE id = %s ",
2300
                           (new_values['contact']['id'],))
2301
            row = cursor.fetchone()
2302
            if row is None:
2303
                cursor.close()
2304
                cnx.close()
2305
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
2306
                                       description='API.CONTACT_NOT_FOUND')
2307
2308
        if cost_center_id is not None:
2309
            cursor.execute(" SELECT name "
@@ 420-430 (lines=11) @@
417
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
418
                                   description='API.SHOPFLOOR_NAME_IS_ALREADY_IN_USE')
419
420
        if contact_id is not None:
421
            cursor.execute(" SELECT name "
422
                           " FROM tbl_contacts "
423
                           " WHERE id = %s ",
424
                           (new_values['data']['contact_id'],))
425
            row = cursor.fetchone()
426
            if row is None:
427
                cursor.close()
428
                cnx.close()
429
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
430
                                       description='API.CONTACT_NOT_FOUND')
431
432
        if cost_center_id is not None:
433
            cursor.execute(" SELECT name "
@@ 152-162 (lines=11) @@
149
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
150
                                   description='API.SHOPFLOOR_NAME_IS_ALREADY_IN_USE')
151
152
        if contact_id is not None:
153
            cursor.execute(" SELECT name "
154
                           " FROM tbl_contacts "
155
                           " WHERE id = %s ",
156
                           (new_values['data']['contact_id'],))
157
            row = cursor.fetchone()
158
            if row is None:
159
                cursor.close()
160
                cnx.close()
161
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
162
                                       description='API.CONTACT_NOT_FOUND')
163
164
        if cost_center_id is not None:
165
            cursor.execute(" SELECT name "

myems-api/core/space.py 3 locations

@@ 4409-4419 (lines=11) @@
4406
            cnx.close()
4407
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
4408
                                   description='API.TIMEZONE_NOT_FOUND')
4409
        if contact_id is not None:
4410
            cursor.execute(" SELECT name "
4411
                           " FROM tbl_contacts "
4412
                           " WHERE id = %s ",
4413
                           (new_values['contact']['id'],))
4414
            row = cursor.fetchone()
4415
            if row is None:
4416
                cursor.close()
4417
                cnx.close()
4418
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
4419
                                       description='API.CONTACT_NOT_FOUND')
4420
4421
        if cost_center_id is not None:
4422
            cursor.execute(" SELECT name "
@@ 656-666 (lines=11) @@
653
            cnx.close()
654
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
655
                                   description='API.TIMEZONE_NOT_FOUND')
656
        if contact_id is not None:
657
            cursor.execute(" SELECT name "
658
                           " FROM tbl_contacts "
659
                           " WHERE id = %s ",
660
                           (new_values['data']['contact_id'],))
661
            row = cursor.fetchone()
662
            if row is None:
663
                cursor.close()
664
                cnx.close()
665
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
666
                                       description='API.CONTACT_NOT_FOUND')
667
668
        if cost_center_id is not None:
669
            cursor.execute(" SELECT name "
@@ 255-265 (lines=11) @@
252
            cnx.close()
253
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
254
                                   description='API.TIMEZONE_NOT_FOUND')
255
        if contact_id is not None:
256
            cursor.execute(" SELECT name "
257
                           " FROM tbl_contacts "
258
                           " WHERE id = %s ",
259
                           (new_values['data']['contact_id'],))
260
            row = cursor.fetchone()
261
            if row is None:
262
                cursor.close()
263
                cnx.close()
264
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
265
                                       description='API.CONTACT_NOT_FOUND')
266
267
        if cost_center_id is not None:
268
            cursor.execute(" SELECT name "