Skip to content

Commit

Permalink
Change default ordering for DOIs in GRAPHQL API
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhoads committed Nov 8, 2024
1 parent 86dc385 commit 3ec1400
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit 3ec1400

Please sign in to comment.