mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-22 23:53:15 +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;
|
margin-bottom: 0.1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-result .metainfo {
|
.search-result .current {
|
||||||
font-size: 0.8rem;
|
font-weight: $font-weight-bold;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,24 @@ class SearchController < ApplicationController
|
||||||
def execute_search
|
def execute_search
|
||||||
@response = Paper.search(@search_definition.to_definition)
|
@response = Paper.search(@search_definition.to_definition)
|
||||||
@papers = @response.page(params[:page]).results
|
@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')
|
@paper_type_facets = extract_facets('paper_types')
|
||||||
@originator_facets = extract_facets('originators')
|
@originator_facets = extract_facets('originators')
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,6 +26,7 @@ class Paper < ActiveRecord::Base
|
||||||
indexes :name, type: :string, analyzer: "german"
|
indexes :name, type: :string, analyzer: "german"
|
||||||
indexes :content, type: :string, analyzer: "german"
|
indexes :content, type: :string, analyzer: "german"
|
||||||
indexes :resolution, 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 :paper_type, type: :string, index: :not_analyzed
|
||||||
indexes :published_at, type: :date, index: :not_analyzed
|
indexes :published_at, type: :date, index: :not_analyzed
|
||||||
indexes :originator, type: :string, index: :not_analyzed
|
indexes :originator, type: :string, index: :not_analyzed
|
||||||
|
|
|
@ -5,8 +5,6 @@ div
|
||||||
- if params[:q].present?
|
- if params[:q].present?
|
||||||
.left
|
.left
|
||||||
| #{@papers.total} Treffer
|
| #{@papers.total} Treffer
|
||||||
.right
|
|
||||||
/ button.button. TODO: Suche Abbonieren
|
|
||||||
- else
|
- else
|
||||||
| #{pluralize(@papers.total, "Dokument", "Dokumente")} in der Datenbank
|
| #{pluralize(@papers.total, "Dokument", "Dokumente")} in der Datenbank
|
||||||
div
|
div
|
||||||
|
@ -14,14 +12,12 @@ div
|
||||||
- @papers.each do |doc|
|
- @papers.each do |doc|
|
||||||
li.search-result
|
li.search-result
|
||||||
article
|
article
|
||||||
h4 = link_to doc.name, doc.url, target: '_blank'
|
h4 = doc.name
|
||||||
div.metainfo
|
ul
|
||||||
span.paper_type = doc.paper_type
|
- @sub[doc.reference].each do |sub|
|
||||||
'
|
li class="#{'current' if sub.reference == doc.reference}"
|
||||||
span.originator = doc.originator
|
div = link_to "#{l sub.published_at.to_date}: #{sub.paper_type} von #{sub.originator.join(", ")}", sub.url, target: '_blank'
|
||||||
'
|
|
||||||
span.published = l doc.published_at.to_date
|
|
||||||
/! score: #{doc._score}
|
|
||||||
|
|
||||||
div#pagination
|
div#pagination
|
||||||
= paginate @papers
|
= paginate @papers
|
||||||
|
|
Loading…
Reference in a new issue