Skip to content

Commit

Permalink
Merge pull request #820 from datacite/repository-sort
Browse files Browse the repository at this point in the history
Sort on non-formatted date field
  • Loading branch information
jrhoads authored Jun 3, 2022
2 parents cde41e2 + bd84d6c commit a7a221e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions app/models/reference_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,14 @@ def as_indexed_json(_options = {})
indexes :client_id
indexes :re3doi
indexes :re3data_url
indexes :created_at, type: :date, format: :date_optional_time
indexes :updated_at, type: :date, format: :date_optional_time
indexes :created_at, type: :date, format: :date_optional_time,
fields: {
created_sort: { type: :date }
}
indexes :updated_at, type: :date, format: :date_optional_time,
fields: {
updated_sort: { type: :date }
}
indexes :name
indexes :alternate_name
indexes :description
Expand Down Expand Up @@ -273,7 +279,7 @@ def query(query, options = {})
def sort_fields
[
{ _score: { order: "desc" } },
{ created_at: { order: "asc" } },
{ "created_at.created_sort": { order: "asc" } },
{ "uid.raw": { order: "asc" } },
]
end
Expand Down
2 changes: 1 addition & 1 deletion spec/graphql/types/repository_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,10 @@
end

before :all do
ReferenceRepository.import(force: true)
VCR.use_cassette("ReferenceRepositoryType/re3Data/R3XS37") do
@client = create(:client)
@ref_repo = create(:reference_repository, client_id: @client.uid, re3doi: "10.17616/R3XS37")
ReferenceRepository.import
sleep 2
end
end
Expand Down

0 comments on commit a7a221e

Please sign in to comment.