diff --git a/app/jobs/delete_orphaned_gbif_events_job.rb b/app/jobs/delete_orphaned_gbif_events_job.rb deleted file mode 100644 index cc76690f5..000000000 --- a/app/jobs/delete_orphaned_gbif_events_job.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -class DeleteOrphanedGbifEventsJob < ApplicationJob - queue_as :lupo_background - - def perform(env, options) - label = "DeleteOrphanedGbifEventsJob_#{Time.now.utc.strftime("%d%m%Y%H%M%S")}" - - Rails.logger.info("#{label}: index_name: #{env}") - Rails.logger.info("#{label}: query: #{options[:query]}") - - # response = Event.delete_by_query(index: env, query: options[:query]) - - # Rails.logger.info(response.to_json) - rescue => err - Rails.logger.info("#{label}: #{err.message}") - end -end diff --git a/lib/tasks/event.rake b/lib/tasks/event.rake index 8a5850413..125f0a87b 100644 --- a/lib/tasks/event.rake +++ b/lib/tasks/event.rake @@ -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