Skip to content

Commit

Permalink
Add a scheduled task to pull and index OGM data
Browse files Browse the repository at this point in the history
Closes #639
  • Loading branch information
thatbudakguy committed Feb 23, 2024
1 parent 438d9b2 commit 1a52d0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
5 changes: 5 additions & 0 deletions config/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@
every 1.day, at: '4:04 am', roles: %i[whenevs] do
rake 'rake earthworks:prune_old_search_data[14]'
end

every :tuesday, at: '5:04 am', roles: %i[whenevs] do
rake 'rake earthworks:opengeometadata:pull'
rake 'rake earthworks:opengeometadata:index'
end
15 changes: 5 additions & 10 deletions lib/tasks/earthworks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,20 @@ namespace :earthworks do
desc 'Initialize OpenGeoMetadata repositories'
task :clone do
harvester = Earthworks::Harvester.new(ogm_repos: Settings.OGM_REPOS)
total = harvester.clone_all
puts "Cloned #{total} repositories"
harvester.clone_all
end

desc 'Fetch updated OpenGeoMetadata records for indexing'
task :pull do
harvester = Earthworks::Harvester.new(ogm_repos: Settings.OGM_REPOS)
total = harvester.pull_all
puts "Updated #{total} repositories"
harvester.pull_all
end

desc 'Index OpenGeoMetadata repositories'
task :index do
task index: :environment do
harvester = Earthworks::Harvester.new(ogm_repos: Settings.OGM_REPOS)
solr_url = Blacklight.connection_config[:url]
indexer = GeoCombine::Indexer.new(solr: RSolr.connect(url: solr_url, adapter: :net_http_persistent))
puts "Indexing #{harvester.ogm_path} into #{indexer.solr_url}"
total = indexer.index(harvester.docs_to_index)
puts "Indexed #{total} documents"
indexer = GeoCombine::Indexer.new
indexer.index(harvester.docs_to_index)
end
end

Expand Down

0 comments on commit 1a52d0c

Please sign in to comment.