Skip to content

Chang default DOI search order #1272

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

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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/controllers/datacite_dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def index
when "relevance"
{ "_score": { "order": "desc" } }
else
{ updated: { order: "desc" } }
{ "_score": { "order": "desc" } }
end

page = page_from_params(params)
Expand Down
2 changes: 1 addition & 1 deletion app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2518,7 +2518,7 @@ def update_publisher_from_hash

def update_publisher_from_string
self.publisher_obj = { name: publisher_before_type_cast }
end
end

def reset_publishers
self.publisher_obj = nil
Expand Down
12 changes: 6 additions & 6 deletions app/models/doi/graphql_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Doi::GraphqlQuery
class Builder
include Modelable

DEFAULT_CURSOR = [0, ""]
DEFAULT_CURSOR = ["Infinity", 0]
DEFAULT_PAGE_SIZE = 0
DEFAULT_FACET_COUNT = 10

Expand All @@ -29,7 +29,7 @@ def size
end

def sort
[{ created: "asc", uid: "asc" }]
[{ _score: "desc", uid: "asc" }]
end

def query_fields
Expand All @@ -47,16 +47,16 @@ def query_fields

def cursor
tmp_cursor = @options.dig(:page, :cursor)
if tmp_cursor.nil?
if tmp_cursor.blank?
return DEFAULT_CURSOR
end

if tmp_cursor.is_a?(Array)
timestamp, uid = tmp_cursor
tmp_score, uid = tmp_cursor
elsif tmp_cursor.is_a?(String)
timestamp, uid = tmp_cursor.split(",")
tmp_score, uid = tmp_cursor.split(",")
end
[timestamp.to_i, uid.to_s]
[tmp_score.to_f, uid.to_s]
end

def search_after
Expand Down