@@ -444,15 +444,25 @@ def process_empty_changeset_from_table(self, table_name, table_columns, osm_id_c
444444
445445 :param osm_id_column: Column name of osm_id
446446 :type osm_id_column: str
447+
448+ :param extra_where: Other where for query
449+ :type extra_where: str
447450 """
448451 # noinspection PyUnboundLocalVariable
449452 connection = self .create_connection ()
450453 cursor = connection .cursor ()
451454 row_batch = {}
452455 osm_ids = []
453456 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+
456466 cursor .execute (check_sql )
457467 row = True
458468 while row :
@@ -461,10 +471,15 @@ def process_empty_changeset_from_table(self, table_name, table_columns, osm_id_c
461471 if row :
462472 row = dict (zip (table_columns , row ))
463473 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 :
466479 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+ )
468483 row_batch = {}
469484 osm_ids = []
470485
@@ -484,9 +499,22 @@ def enrich_empty_changeset(self):
484499 osm_type = table_data ['osm_type' ]
485500 columns = table_data ['columns' ]
486501 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+ )
490518 else :
491519 self .info ('Does not know osm_id column for %s.' % table )
492520
0 commit comments