query="SELECT \"versions\".* FROM \"versions\" WHERE \"versions\".\"item_type\" = 'LettingsLog' AND whodunnit is null AND ((object_changes like '%status:\n- 3\n- 1%') OR (object_changes like '%status:\n- 3\n- 2%'))"
csv<<[id,log.collection_start_year,log.status,log.owning_organisation_name,log.assigned_to_id,log.assigned_to.email,"Leave","Log has no visible duplicates and at least one duplicate has been deleted since being affected"]
next
end
ifvisible_duplicates.length.zero?
seen.add(id)
csv<<[id,log.collection_start_year,log.status,log.owning_organisation_name,log.assigned_to_id,log.assigned_to.email,"Leave","Log has no visible duplicates"]
next
end
unaffected_duplicates=[]
affected_updated_duplicates=[]
affected_non_updated_duplicates=[log]
visible_duplicates.eachdo|dup|
vquery="SELECT \"versions\".* FROM \"versions\" WHERE \"versions\".\"item_type\" = 'LettingsLog' AND \"versions\".\"item_id\" = #{dup.id} AND whodunnit is null AND ((object_changes like '%status:\n- 3\n- 1%') OR (object_changes like '%status:\n- 3\n- 2%'))"
csv<<[d.id,d.collection_start_year,d.status,d.owning_organisation_name,d.assigned_to_id,d.assigned_to.email,"Leave","Log updated in UI"]
end
end
affected_non_updated_duplicates.eachdo|d|
seen.add(d.id)
csv<<[d.id,d.collection_start_year,d.status,d.owning_organisation_name,d.assigned_to_id,d.assigned_to.email,"Delete","Log is a duplicate of unaffected log(s)",unaffected_logs_reference]
csv<<[d.id,d.collection_start_year,d.status,d.owning_organisation_name,d.assigned_to_id,d.assigned_to.email,"Leave","Log updated in UI"]
end
end
affected_non_updated_duplicates.eachdo|d|
seen.add(d.id)
csv<<[d.id,d.collection_start_year,d.status,d.owning_organisation_name,d.assigned_to_id,d.assigned_to.email,"Delete","Log is a duplicate of log(s) which have been updated since being affected",updated_logs_reference]
csv<<[latest_created.id,latest_created.collection_start_year,latest_created.status,latest_created.owning_organisation_name,latest_created.assigned_to_id,latest_created.assigned_to.email,"Leave","Log is the most recently created of a duplicate group"]
affected_non_updated_duplicates.eachdo|d|
nextunlessd.id!=latest_created.id
seen.add(d.id)
csv<<[d.id,d.collection_start_year,d.status,d.owning_organisation_name,d.assigned_to_id,d.assigned_to.email,"Delete","Log is a duplicate of more recently created affected log",latest_created.id]