diff --git a/apps/dnet-orgs-database-application/src/main/resources/sql/importDedupEvents.sql b/apps/dnet-orgs-database-application/src/main/resources/sql/importDedupEvents.sql index 146050e3..927faa7f 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/sql/importDedupEvents.sql +++ b/apps/dnet-orgs-database-application/src/main/resources/sql/importDedupEvents.sql @@ -50,4 +50,12 @@ WHERE c1.oid != c2.oid ON CONFLICT DO NOTHING; + +-- CONSISTENCY + +-- Remove invalid suggestions (an existing relation has already been approved) +DELETE FROM oa_duplicates d +USING oa_duplicates d1 +WHERE d.oa_original_id = d1.oa_original_id AND d.reltype = 'suggested' AND d1.reltype = 'is_similar'; + COMMIT; diff --git a/apps/dnet-orgs-database-application/src/main/resources/sql/someConsistencyQueries.sql b/apps/dnet-orgs-database-application/src/main/resources/sql/someConsistencyQueries.sql new file mode 100644 index 00000000..89ee3fec --- /dev/null +++ b/apps/dnet-orgs-database-application/src/main/resources/sql/someConsistencyQueries.sql @@ -0,0 +1,2 @@ +-- TO RESOLVE MANUALLY MANAGING CONFLICTS +select d.oa_original_id, array_agg(o.id), array_agg(o.name) from oa_duplicates d left outer join organizations o on (o.id = d.local_id) where d.reltype='is_similar' group by oa_original_id having count(reltype) > 1 and count (distinct o.status) = 1;