Exclude deindexed images from the ingestion process
@@ -247,7 +247,10 @@ def reload_upstream(table, progress=None, finish_time=None):
CREATE TABLE temp_import_{table} (LIKE {table} INCLUDING CONSTRAINTS);
CREATE TEMP SEQUENCE IF NOT EXISTS image_id_temp_seq;
INSERT INTO temp_import_{table} ({cols})
- SELECT {insert_cols} from upstream_schema.{table};
+ SELECT {insert_cols} from upstream_schema.{table} img
+ WHERE NOT EXISTS(
+ SELECT FROM api_deletedimage WHERE identifier = img.identifier
+ );
ALTER TABLE temp_import_{table} ADD PRIMARY KEY (id);
DROP SERVER upstream CASCADE;
'''.format(table=table, cols=query_cols, insert_cols=query_cols_nextval)
