Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: NOP-22 Sort by Date Newest and oldest- not working as expected #965

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/indexers/work_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def related_record_title_markup(ursus_url, title)
def add_dates(solr_doc)
valid_dates = solr_dates
solr_doc['date_dtsim'] = valid_dates if valid_dates
solr_doc['date_dtsort'] = solr_doc['date_dtsim'][0] if solr_doc['date_dtsort']
solr_doc['date_dtsort'] = solr_doc['date_dtsim'][0] if solr_doc['date_dtsim']
end

def combined_subject
Expand Down
3 changes: 3 additions & 0 deletions spec/indexers/work_indexer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@
it 'indexes the year' do
expect(solr_document['year_isim']).to eq [1940]
expect(solr_document['date_dtsim']).to eq [Date.strptime('1940', "%Y").to_time.utc.iso8601]
expect(solr_document['date_dtsort']).to eq '1940-01-01T00:00:00Z'
end
end

Expand Down Expand Up @@ -345,6 +346,7 @@
it 'indexes the earliest year' do
expect(solr_document['sort_year_isi']).to eq 1940
expect(solr_document['date_dtsim']).to eq [Date.strptime('1940-10-15', "%Y-%m-%d").to_time.utc.iso8601]
expect(solr_document['date_dtsort']).to eq '1940-10-15T00:00:00Z'
end
end

Expand Down Expand Up @@ -372,6 +374,7 @@
it 'indexes the earliest year' do
expect(solr_document['sort_year_isi']).to eq 1934
expect(solr_document['date_dtsim']).to eq [Date.strptime('1934-06', "%Y-%m").to_time.utc.iso8601, Date.strptime('1937-07', "%Y-%m").to_time.utc.iso8601]
expect(solr_document['date_dtsort']).to eq '1934-06-01T00:00:00Z'
end
end

Expand Down
Loading