mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-22 15:43:14 +01:00
12: Group sequential papers in search results
#12: Group sequential papers in search results - use consistent layout
This commit is contained in:
parent
7f1aead3a8
commit
52f93fcb42
4 changed files with 27 additions and 12 deletions
|
@ -12,6 +12,6 @@
|
|||
margin-bottom: 0.1rem;
|
||||
}
|
||||
|
||||
.search-result .metainfo {
|
||||
font-size: 0.8rem;
|
||||
.search-result .current {
|
||||
font-weight: $font-weight-bold;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,24 @@ class SearchController < ApplicationController
|
|||
def execute_search
|
||||
@response = Paper.search(@search_definition.to_definition)
|
||||
@papers = @response.page(params[:page]).results
|
||||
@sub = Hash.new
|
||||
@papers.each do |paper|
|
||||
@sub_search_definition = Elasticsearch::DSL::Search.search do
|
||||
query do
|
||||
query_string do
|
||||
query "*" + (paper.reference.start_with?("VI-") ? paper.reference.split("-")[2] : paper.reference.split("-")[1]) + "*"
|
||||
fields ["reference"]
|
||||
end
|
||||
end
|
||||
|
||||
sort do
|
||||
by :published_at, order: 'asc'
|
||||
by :reference, order: 'asc'
|
||||
end
|
||||
end
|
||||
@sub_papers = Paper.search(@sub_search_definition)
|
||||
@sub[paper.reference] = @sub_papers
|
||||
end
|
||||
@paper_type_facets = extract_facets('paper_types')
|
||||
@originator_facets = extract_facets('originators')
|
||||
end
|
||||
|
|
|
@ -26,6 +26,7 @@ class Paper < ActiveRecord::Base
|
|||
indexes :name, type: :string, analyzer: "german"
|
||||
indexes :content, type: :string, analyzer: "german"
|
||||
indexes :resolution, type: :string, analyzer: "german"
|
||||
indexes :reference, type: :string, index: :not_analyzed
|
||||
indexes :paper_type, type: :string, index: :not_analyzed
|
||||
indexes :published_at, type: :date, index: :not_analyzed
|
||||
indexes :originator, type: :string, index: :not_analyzed
|
||||
|
|
|
@ -5,8 +5,6 @@ div
|
|||
- if params[:q].present?
|
||||
.left
|
||||
| #{@papers.total} Treffer
|
||||
.right
|
||||
/ button.button. TODO: Suche Abbonieren
|
||||
- else
|
||||
| #{pluralize(@papers.total, "Dokument", "Dokumente")} in der Datenbank
|
||||
div
|
||||
|
@ -14,14 +12,12 @@ div
|
|||
- @papers.each do |doc|
|
||||
li.search-result
|
||||
article
|
||||
h4 = link_to doc.name, doc.url, target: '_blank'
|
||||
div.metainfo
|
||||
span.paper_type = doc.paper_type
|
||||
'
|
||||
span.originator = doc.originator
|
||||
'
|
||||
span.published = l doc.published_at.to_date
|
||||
/! score: #{doc._score}
|
||||
h4 = doc.name
|
||||
ul
|
||||
- @sub[doc.reference].each do |sub|
|
||||
li class="#{'current' if sub.reference == doc.reference}"
|
||||
div = link_to "#{l sub.published_at.to_date}: #{sub.paper_type} von #{sub.originator.join(", ")}", sub.url, target: '_blank'
|
||||
|
||||
|
||||
div#pagination
|
||||
= paginate @papers
|
||||
|
|
Loading…
Reference in a new issue