Skip to content

Commit

Permalink
Pagination and sorting of digest by recency (#2374)
Browse files Browse the repository at this point in the history
* paginate and sort

* paginated for 100 items
  • Loading branch information
grvsachdeva authored and jywarren committed Feb 26, 2018
1 parent c866602 commit b676b6b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/subscription_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ def delete

def digest
@wikis = current_user.content_followed_in_period(Time.now - 1.week, Time.now)
.paginate(page: params[:page], per_page: 100)

@paginated = true
render :template => "subscriptions/digest"
end

Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def content_followed_in_period(start_time, end_time)
.includes(:revision, :tag)
.references(:node_revision)
.where("(created >= #{start_time.to_i} AND created <= #{end_time.to_i}) OR (timestamp >= #{start_time.to_i} AND timestamp <= #{end_time.to_i})")
.order('node_revisions.timestamp DESC')
.uniq
end

Expand Down

0 comments on commit b676b6b

Please sign in to comment.