Skip to content

Commit

Permalink
change orphan delete implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
wendelfabianchinsamy committed Jul 23, 2024
1 parent 1de05dd commit 7cf2554
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
18 changes: 0 additions & 18 deletions app/jobs/delete_orphaned_gbif_events_job.rb

This file was deleted.

16 changes: 6 additions & 10 deletions lib/tasks/event.rake
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,13 @@ namespace :gbif_events do

desc "delete orphaned gbif_events"
task delete_orphaned_gbif_events: :environment do
options = {
size: 1000,
from_id: (ENV["FROM_ID"] || Event.minimum(:id)).to_i,
until_id: (ENV["UNTIL_ID"] || Event.maximum(:id)).to_i,
filter: {},
query: "+subj.registrantId:datacite.gbif.gbif +relation_type_id:references -source_doi:(\"10.15468/QJGWBA\" OR \"10.35035/GDWQ-3V93\" OR \"10.15469/3XSWXB\" OR \"10.15469/UBP6QO\" OR \"10.35000/TEDB-QD70\" OR \"10.15469/2YMQOZ\")",
label: "gbif_orphaned_gbif_events_job_#{Time.now.utc.strftime("%d%m%Y%H%M%S")}",
job_name: "DeleteOrphanedGbifEventsJob"
}
index = ENV["INDEX"]
query = "+subj.registrantId:datacite.gbif.gbif +relation_type_id:references -source_doi:(\"10.15468/QJGWBA\" OR \"10.35035/GDWQ-3V93\" OR \"10.15469/3XSWXB\" OR \"10.15469/UBP6QO\" OR \"10.35000/TEDB-QD70\" OR \"10.15469/2YMQOZ\")"
label = "DeleteOrphanedGbifEventsJob_#{Time.now.utc.strftime("%d%m%Y%H%M%S")}"
Rails.logger.info("#{label}: index: #{index}")
Rails.logger.info("#{label}: query: #{query}")

Event.loop_through_events(options)
response = Event.delete_by_query(index: index, query: query)
end
end

Expand Down

0 comments on commit 7cf2554

Please sign in to comment.