Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/entities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def show

# GET /entities/autocomplete?search=*
def autocomplete
query = strip_tags params[:searcn]
query = strip_tags params[:search]
render json: Entity.search(
query,
fields: [:clean_label],
Expand Down
2 changes: 2 additions & 0 deletions app/models/published_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class PublishedEntity < ApplicationRecord

self.table_name = 'entities'

has_many :letters, -> { where(published: true).order('letters.date') }, through: :mentions, source: :letter

def self.default_scope
where(published: true)
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/entities/letters.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ json.set! 'max_date', @max_date&.strftime('%Y-%m-%d')
json.set! 'total_pages', @letters.total_pages

json.letters do
@letters.each do |letter|
@letters.select(&:published).each do |letter|
json.child! do
json.set! 'id', letter.id
json.set! 'label', letter.label
json.set! 'recipient', letter.recipients.map(&:label).to_sentence
json.set! 'repository', letter.repositories.map(&:label).to_sentence
json.set! 'repository', letter.repositories.select(&:published).map(&:label).to_sentence
json.set! 'date', letter.date&.strftime('%d %B %Y')
next unless @relation == 'mention'

Expand Down