Skip to content

Commit

Permalink
Update recent wiki pages; paginate
Browse files Browse the repository at this point in the history
  • Loading branch information
vasi committed Sep 8, 2016
1 parent 57c3189 commit e21843e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
12 changes: 7 additions & 5 deletions app/controllers/recent_wiki_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
class RecentWikiPagesController < ApplicationController
def self.pages_with_updated_on
WikiPage.with_updated_on
.joins(:content)
.order("#{WikiContent.table_name}.updated_on DESC")
end

def date_index
@pages = WikiPage.find :all,
:select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on",
:joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id",
:order => "#{WikiContent.table_name}.updated_on DESC"
@paginator, @pages = paginate self.class.pages_with_updated_on
@pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
@pages_by_parent_id = @pages.group_by(&:parent_id)

@pages.first.wiki
end
Expand Down
4 changes: 3 additions & 1 deletion app/views/my/blocks/_recent_wiki_pages.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<%
#see WikiController::load_pages_for_index
pages = WikiPage.with_updated_on.find :all, :order => "updated_on DESC", :limit => 10,:include => {:wiki => :project}
pages = RecentWikiPagesController.pages_with_updated_on
.limit(10)
.includes(:wiki => :project)
%>

<span style="display:inline-block"> <h3>Top 10 Most Recent Wiki Pages</h3></span>
Expand Down
4 changes: 4 additions & 0 deletions app/views/recent_wiki_pages/date_index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
<% end %>
</ul>
<% end %>

<span class="pagination">
<%= pagination_links_full @paginator, :per_page_links => true %>
</span>

0 comments on commit e21843e

Please sign in to comment.