Skip to content

Commit

Permalink
Merge pull request #94 from Det-Kongelige-Bibliotek/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
siglun authored May 23, 2018
2 parents 12c947b + 3674626 commit ca4c56a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
/cache/*
!/log/.keep
!/tmp/.keep
!/cache/.keep

# Ignore Byebug command history file.
.byebug_history
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ class CatalogController < ApplicationController

config.add_search_field 'all_fields', label: 'Fritekst' do |field|
# Free text search in these fields: title, creator, description
field.solr_local_parameters = {
:qf => 'cobject_title_ssi^100 full_title_tsi^90 creator_tsim^80 description_tsim^50 pub_dat_tsi^40 readable_dat_string_tsim^40 type_tdsim^30 dc_type_ssim^30 subject_tdsim^30 coverage_tdsim^30 local_id_ssi^30 shelf_mark_tdsim^20 subject_topic_facet_tdsim^20 subject_topic_facet_tesim^20 processed_mods_ts^10'
field.solr_parameters = {
:qf => 'cobject_title_ssi^100 full_title_tsi^90 creator_tsim^80 description_tsim^50 pub_dat_tsi^40 readable_dat_string_tsim^40 type_tdsim^30 dc_type_ssim^30 subject_tdsim^30 subject_tesim^30 coverage_tdsim^30 local_id_ssi^30 shelf_mark_tdsim^20 subject_topic_facet_tdsim^20 subject_topic_facet_tesim^20 processed_mods_ts^10'
}
end

Expand All @@ -139,31 +139,31 @@ class CatalogController < ApplicationController

config.add_search_field 'title', label: 'Titel' do |field|

field.solr_local_parameters = {
field.solr_parameters = {
qf: 'full_title_tsi',
pf: 'full_title_tsi'
}
end

config.add_search_field 'creator', label: 'Ophav' do |field|

field.solr_local_parameters = {
field.solr_parameters = {
qf: 'creator_nasim',
pf: 'creator_nasim'
}
end

config.add_search_field 'person', label: 'Person' do |field|

field.solr_local_parameters = {
field.solr_parameters = {
qf: 'cobject_person_tsim',
pf: 'cobject_person_tsim'
}
end

config.add_search_field 'location', label: 'Lokalitet' do |field|

field.solr_local_parameters = {
field.solr_parameters = {
qf: 'cobject_location_tsim',
pf: 'cobject_location_tsim'
}
Expand Down
18 changes: 11 additions & 7 deletions app/models/finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ def self.get_solr

# Function to return the solr document by id
def self.get_doc_by_id(id)
query = "id:#{id}"
response = get_solr.get 'select', :params => {:q => query}
# Return the first document
return response['response']['docs'].first
Rails.cache.fetch("document/#{id}", expires_in: 3.hours) do
query = "id:#{id}"
response = get_solr.get 'select', :params => {:q => query}
# Return the first document
response['response']['docs'].first
end
end

# Function to return the solr documents that are subcategories, searching by id
def self.get_subcats_by_id id
query = "parent_ssi:#{id}" # Set the query
response = get_solr.get 'select', :params => {:q => query, :rows => 1000} # Return all the subcategories (by default the rows: 10)
return response['response']['docs'].delete_if { |x| x["id"]=="/images/luftfo/2011/maj/luftfoto/subject203" } # Return all the documents except luftfoto
Rails.cache.fetch("subcats/#{id}", expires_in: 3.hours) do
query = "parent_ssi:#{id}" # Set the query
response = get_solr.get 'select', :params => {:q => query, :rows => 1000} # Return all the subcategories (by default the rows: 10)
response['response']['docs'].delete_if { |x| x["id"]=="/images/luftfo/2011/maj/luftfoto/subject203" } # Return all the documents except luftfoto
end
end

end
2 changes: 1 addition & 1 deletion app/views/catalog/_home_text.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<% #exhibits.each_slice(3).each do |row| %>
<div class="row"><!-- start main content row -->
<% cache("edition-cards-#{get_lang(params)}", expires_in: 1.hour) do %>
<% cache("edition-cards-#{get_lang(params)}", expires_in: 3.hour) do %>
<%= render partial: 'edition_card' %>
<% end %>
</div>
Expand Down
8 changes: 2 additions & 6 deletions app/views/tree/_show_tree.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ different format for the facets (I think it's bug in Blacklight)-->

<% if subject_id %>
<!--Show the tree -->
<% cache("#{subject_id.gsub('/','#')}-#{get_lang(params)}", expires_in: 1.hour) do %>
<%= render :partial => 'tree/tree', locals: {:subject_id => subject_id, :lang => lang, :filter_params_url => filter_params_url} %>
<% end %>
<%= render :partial => 'tree/tree', locals: {:subject_id => subject_id, :lang => lang, :filter_params_url => filter_params_url} %>
<% else %>
<% cache("subject-all-#{get_lang(params)}", expires_in: 1.hour) do %>
<%= render :partial => 'tree/tree', locals: {:subject_id => "/editions/any/2009/jul/editions", :lang => lang, :filter_params_url => filter_params_url} %>
<% end %>
<%= render :partial => 'tree/tree', locals: {:subject_id => "/editions/any/2009/jul/editions", :lang => lang, :filter_params_url => filter_params_url} %>
<% end %>
Empty file added cache/.keep
Empty file.

0 comments on commit ca4c56a

Please sign in to comment.