From 3ec1400772066af99c1ad81de8b0e64cae1d29f3 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Fri, 8 Nov 2024 13:31:17 +0100 Subject: [PATCH] Change default ordering for DOIs in GRAPHQL API --- app/models/doi/graphql_query.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/doi/graphql_query.rb b/app/models/doi/graphql_query.rb index 6c10d1599..5461676d5 100644 --- a/app/models/doi/graphql_query.rb +++ b/app/models/doi/graphql_query.rb @@ -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 @@ -29,7 +29,7 @@ def size end def sort - [{ created: "asc", uid: "asc" }] + [{ _score: "desc", uid: "asc" }] end def query_fields @@ -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