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<<[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,"Delete","Log is a duplicate of log(s) which have been updated since being affected",updated_logs_reference]
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]