Skip to content

Commit

Permalink
Fixed notes_controller so that notes are sorted by likes (publiclab#6919
Browse files Browse the repository at this point in the history
)

* Fixed notes_controller so that notes are sort by likes

The notes were being ordered through their 'nid' which I assume means node id instead of their 'cached_likes' count. I think this is the solution to problem and it worked on my local machine. I looked at schema for the nodes and think this is what they need to be ordered by.

* now /notes/recent will be sorted from most recent to least
  • Loading branch information
Uzay-G authored and jywarren committed Dec 7, 2019
1 parent 3c4dfc5 commit b0c03f5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def liked
@notes = Node.research_notes
.where(status: 1)
.limit(20)
.order('nid DESC')
.order('cached_likes DESC')
@unpaginated = true
render template: 'notes/index'
end
Expand All @@ -298,6 +298,7 @@ def recent
.where(type: 'page', status: 1)
.order('nid DESC')
@notes = Node.where(type: 'note', status: 1, created: Time.now.to_i - 1.weeks.to_i..Time.now.to_i)
.order('created DESC')
@unpaginated = true
render template: 'notes/index'
end
Expand Down

0 comments on commit b0c03f5

Please sign in to comment.