Skip to content

Commit

Permalink
cursor-based pagination for activities api. #238
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Apr 12, 2019
1 parent d9e0017 commit c648f11
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def query(query, options={})
from = 0
search_after = [options.dig(:page, :cursor)]
sort = [{ _id: { order: 'asc' }}]
elsif self.name == "Activity" && options.dig(:page, :cursor).present?
from = 0
search_after = [options.dig(:page, :cursor)]
sort = [{ created: { order: 'asc' }}]
else
from = (options.dig(:page, :number) - 1) * options.dig(:page, :size)
search_after = nil
Expand Down

0 comments on commit c648f11

Please sign in to comment.