@@ -444,15 +444,25 @@ def process_empty_changeset_from_table(self, table_name, table_columns, osm_id_c
444
444
445
445
:param osm_id_column: Column name of osm_id
446
446
:type osm_id_column: str
447
+
448
+ :param extra_where: Other where for query
449
+ :type extra_where: str
447
450
"""
448
451
# noinspection PyUnboundLocalVariable
449
452
connection = self .create_connection ()
450
453
cursor = connection .cursor ()
451
454
row_batch = {}
452
455
osm_ids = []
453
456
try :
454
- check_sql = ''' select * from %s."%s" WHERE "changeset_timestamp"
455
- IS NULL AND "osm_id" IS NOT NULL ORDER BY "osm_id" ''' % (self .default ['DBSCHEMA_PRODUCTION' ], table_name )
457
+ check_sql = f'''
458
+ select * from { self .default ['DBSCHEMA_PRODUCTION' ]} .{ table_name } WHERE "changeset_timestamp"
459
+ IS NULL AND "{ osm_id_column } " IS NOT NULL
460
+ '''
461
+ if extra_where :
462
+ check_sql += f' AND { extra_where } '
463
+
464
+ check_sql += f''' ORDER BY "{ osm_id_column } "'''
465
+
456
466
cursor .execute (check_sql )
457
467
row = True
458
468
while row :
@@ -461,10 +471,15 @@ def process_empty_changeset_from_table(self, table_name, table_columns, osm_id_c
461
471
if row :
462
472
row = dict (zip (table_columns , row ))
463
473
row_batch ['%s' % row [osm_id_column ]] = row
464
- osm_ids .append ('%s' % row [osm_id_column ])
465
- if len (osm_ids ) == 30 :
474
+ try :
475
+ osm_ids .append (f'{ abs (row [osm_id_column ])} ' )
476
+ except :
477
+ osm_ids .append ('%s' % row [osm_id_column ])
478
+ if len (osm_ids ) == 20 :
466
479
self .update_osm_enrich_from_api_in_batch (
467
- osm_ids , osm_type , row_batch , table_name , osm_id_column )
480
+ osm_ids , osm_type , row_batch , table_name ,
481
+ osm_id_column
482
+ )
468
483
row_batch = {}
469
484
osm_ids = []
470
485
@@ -484,9 +499,22 @@ def enrich_empty_changeset(self):
484
499
osm_type = table_data ['osm_type' ]
485
500
columns = table_data ['columns' ]
486
501
if osm_id_columnn is not None :
487
- self .info ('Checking data from table %s' % table )
488
- self .process_empty_changeset_from_table (
489
- table , columns , osm_id_columnn , osm_type )
502
+ if osm_type == 'way' :
503
+ self .info ('Checking data from table %s with type way' % table )
504
+ self .process_empty_changeset_from_table (
505
+ table , columns , osm_id_columnn , 'way' ,
506
+ extra_where = f'"{ osm_id_columnn } " > 0'
507
+ )
508
+ self .info ('Checking data from table %s with type relation' % table )
509
+ self .process_empty_changeset_from_table (
510
+ table , columns , osm_id_columnn , 'relation' ,
511
+ extra_where = f'"{ osm_id_columnn } " < 0'
512
+ )
513
+ else :
514
+ self .info ('Checking data from table %s' % table )
515
+ self .process_empty_changeset_from_table (
516
+ table , columns , osm_id_columnn , osm_type
517
+ )
490
518
else :
491
519
self .info ('Does not know osm_id column for %s.' % table )
492
520
0 commit comments