Skip to content

Commit

Permalink
gets rid of monthly catchup. Redoes catchup since
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Jun 5, 2024
1 parent db6924e commit 3184444
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 45 deletions.
59 changes: 42 additions & 17 deletions umich_catalog_indexing/bin/catchup_since.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@

require "optparse"
require "optparse/date"
require 'logger'
require 'date'
require_relative "../lib/sidekiq_jobs"
require_relative "../lib/index_for_date"
require_relative "../lib/index_alma_for_date"
require_relative "../lib/index_zephir_for_date"

logger = S.logger

today = Date.today
date = Date.new(today.year, today.month, 1) #First of the month

logger = Logger.new($stdout)
date = DateTime.now.strftime("%Y%m%d")
solr_url = ENV.fetch("REINDEX_SOLR_URL")
path = ENV.fetch("DAILY_ALMA_FILES_PATH")
OptionParser.new do |opts|
opts.on("-d", "--date=DATE", Date, "Date from which to catchup from. Default is today") do |x|
alma_path = ENV.fetch("DAILY_ALMA_FILES_PATH")
zephir_path = "production/zephir_daily"

opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: catchup_alma_since.rb [options] alma||zephir||both"
opts.on("-d", "--date=DATE", Date, "Date from which to catchup from. Default is the first of the current month") do |x|
raise ArgumentError, "date must be today or earlier" if x > Date.today
date = x.strftime("%Y%m%d")
end
Expand All @@ -28,18 +34,37 @@
raise ArgumentError, "solr must be reindex|hatcher_prod|macc_prod"
end
end
opts.on("-h", "--help", "Prints this help") do
puts opts
exit
end


opts.on("-h", "--help", "Prints this help") do
puts opts
exit
end
end.parse!

alma_files = SFTP.client.ls(path)
if ARGV.empty? || !(["alma","zephir", "both" ].include?(ARGV[0]) )
puts optparse
exit(-1)
end

start_date = DateTime.parse(date)
start_date.upto(DateTime.now) do |date|
date_string = date.strftime("%Y%m%d")
logger.info "Indexing #{date_string}"
IndexForDate.new(alma_files: alma_files,date: date_string, solr_url: solr_url).run
repository = ARGV[0]
if ["both","alma"].include?(repository)
index(repository: "alma", dir: alma_path)
end
if ["both","zephir"].include?(repository)
index(repository: "zephir", dir: zephir_path)
end


def index(repository:, dir:)
file_paths = SFTP.client.ls(dir)

start_date = DateTime.parse(date)
start_date.upto(DateTime.now) do |date|
date_string = date.strftime("%Y%m%d")
logger.info "========================"
logger.info "Indexing #{repository}.capitalize #{date_string}"
logger.info "========================"
Object.const_get("Index#{repository.capitalize}ForDate").new(file_paths: file_paths, date: date_string, solr_url: solr_url).run
end
end
25 changes: 0 additions & 25 deletions umich_catalog_indexing/bin/monthly_catchup.rb

This file was deleted.

3 changes: 1 addition & 2 deletions umich_catalog_indexing/lib/index_alma_for_date.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
$:.unshift "#{File.dirname(__FILE__)}"
require "date"
require "sidekiq_jobs"
require_relative "sidekiq_jobs"

class IndexAlmaForDate
def initialize(file_paths:, date:, solr_url:,
Expand Down
3 changes: 2 additions & 1 deletion umich_catalog_indexing/lib/index_zephir_for_date.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "sidekiq_jobs"
require "date"
require_relative "sidekiq_jobs"

class IndexZephirForDate
def initialize(file_paths:, date:, solr_url:,
Expand Down

0 comments on commit 3184444

Please sign in to comment.