mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-22 23:53:15 +01:00
Show the number of all papers on homepage
This commit is contained in:
parent
40eeac2021
commit
553c1e653c
2 changed files with 8 additions and 4 deletions
|
@ -1,10 +1,12 @@
|
||||||
class SearchController < ApplicationController
|
class SearchController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@show_search_result = params[:q].present?
|
@show_search_result = params[:q].present?
|
||||||
@papers = if @show_search_result
|
papers_found = if @show_search_result
|
||||||
Paper.search(params[:q]).page(params[:page]).results
|
Paper.search(params[:q])
|
||||||
else
|
else
|
||||||
Paper.order(published_at: :desc).page(params[:page])
|
Paper.order(published_at: :desc)
|
||||||
end
|
end
|
||||||
|
@papers_count = @show_search_result ? papers_found.results.total : papers_found.count
|
||||||
|
@papers = papers_found.page(params[:page])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,9 +4,11 @@ div
|
||||||
.clearfix
|
.clearfix
|
||||||
- if @show_search_result
|
- if @show_search_result
|
||||||
.left
|
.left
|
||||||
| #{@papers.total} Treffer
|
| #{@papers_count} Treffer
|
||||||
.right
|
.right
|
||||||
button.button. TODO: Suche Abbonieren
|
button.button. TODO: Suche Abbonieren
|
||||||
|
- else
|
||||||
|
| #{@papers_count} Dokumente in der Datenbank
|
||||||
div
|
div
|
||||||
ul.no-bullet
|
ul.no-bullet
|
||||||
- @papers.each do |doc|
|
- @papers.each do |doc|
|
||||||
|
|
Loading…
Reference in a new issue