From: Bill Erickson Date: Tue, 6 Nov 2018 15:52:59 +0000 (-0500) Subject: indexer start-date support X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=615a1419f44090950ab665bea1a1c14785f758ee;p=working%2FEvergreen.git indexer start-date support Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Elastic/BibSearch.pm b/Open-ILS/src/perlmods/lib/OpenILS/Elastic/BibSearch.pm index e451259db5..86abb412a6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Elastic/BibSearch.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Elastic/BibSearch.pm @@ -216,17 +216,25 @@ sub get_bib_ids { my $start_id = $state->{start_record} || 0; my $stop_id = $state->{stop_record}; # TODO - - # TODO: implement start_date filtering. - # Requires checking edit dates on bibs, call numbers, and copies! my $start_date = $state->{start_date}; - my $sql = <= $start_id -ORDER BY bre.edit_date, bre.id LIMIT $BIB_BATCH_SIZE -SQL + my ($select, $from, $where, $order); + if ($start_date) { + $select = "SELECT id"; + $from = "FROM elastic.bib_last_mod_date"; + $where = "WHERE last_mod_date > '$start_date'"; + $order = "ORDER BY last_mod_date"; + } else { + $select = "SELECT id"; + $from = "FROM biblio.record_entry"; + $where = "WHERE NOT deleted AND active"; + $order = "ORDER BY edit_date, id"; + } + + $where .= " AND id >= $start_id" if $start_id; + $where .= " AND id <= $stop_id" if $stop_id; + + my $sql = "$select $from $where $order LIMIT $BIB_BATCH_SIZE"; my $ids = $self->get_db_rows($sql); return [ map {$_->{id}} @$ids ]; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.elastic-search.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.elastic-search.sql index 97adf226c2..743f5f160b 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.elastic-search.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.elastic-search.sql @@ -134,6 +134,29 @@ BEGIN $$; END $FUNK$ LANGUAGE PLPGSQL; +/* give me bibs I should upate */ + +CREATE OR REPLACE VIEW elastic.bib_last_mod_date AS + WITH mod_dates AS ( + SELECT bre.id, + bre.edit_date, + MAX(acn.edit_date) AS max_call_number_edit_date, + MAX(acp.edit_date) AS max_copy_edit_date + FROM biblio.record_entry bre + JOIN asset.call_number acn ON (acn.record = bre.id) + JOIN asset.copy acp ON (acp.call_number = acn.id) + WHERE + bre.active + AND NOT bre.deleted + AND NOT acn.deleted + AND NOT acp.deleted + GROUP BY 1, 2 + ) SELECT dates.id, + GREATEST(dates.edit_date, + GREATEST(dates.max_call_number_edit_date, dates.max_copy_edit_date) + ) AS last_mod_date + FROM mod_dates dates; + /* SEED DATA ------------------------------------------------------------ */