Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16041 16103 uncache #524

Merged
merged 3 commits into from
Feb 4, 2019
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/views/notices/search/_date_range_filter.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<li class="facet"><a href="javascript:void(0);" data-facet-name="<%= date_range_filter.parameter %>" data-value="">All</a></li>
<% results[date_range_filter.parameter.to_s]['buckets'].each do |range| %>
<li class="facet <%= facet_active_indicator(date_range_filter.parameter, range_facet_param(range)) %>" name="<%= date_range_filter.parameter %>" >
<a href="javascript:void(0);" data-facet-name="<%= date_range_filter.parameter %>" data-value="<%= range_facet_param(range) %>">Since <%= formatted_facet_range_time(range['from']) %><span class="total-count"><%= range[:doc_count] %> Results</span></a>
<a href="javascript:void(0);" data-facet-name="<%= date_range_filter.parameter %>" data-value="<%= range_facet_param(range) %>">Since <%= formatted_facet_range_time(range['from']) %> <span class="total-count"><%= range[:doc_count] %> Results</span></a>
</li>
<% end %>
</ol>
Expand Down
24 changes: 11 additions & 13 deletions app/views/notices/search/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@
<span class="total-entries">Found <%= @searchdata.results.total %> results</span>
<div class="dropdown sort-order">
Sort by: <a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0)"><%= sort_order_label(params[:sort_by]) %></a>
<% cache 'sortings' do %>
<ol class="dropdown-menu" role="menu">
<% Notice::SORTINGS.each do |sorting| %>
<li class="facet">
<%=
link_to(
sorting.label, '#', 'data-value': sorting.key,
'data-label': sorting.label
) %>
</li>
<% end %>
</ol>
<% end %>
<ol class="dropdown-menu" role="menu">
<% Notice::SORTINGS.each do |sorting| %>
<li class="facet">
<%=
link_to(
sorting.label, '#', 'data-value': sorting.key,
'data-label': sorting.label
) %>
</li>
<% end %>
</ol>
</div>
</div>
</header>
Expand Down
26 changes: 10 additions & 16 deletions app/views/shared/_header_search.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,18 @@
<%= render 'shared/search' %>
</div>
<%= form_tag(notices_search_index_path, method: :get) do %>
<%# Don't cache the entire page, because caching the form caches its
authenticity token, which will break that security feature. However,
do cache this section; it's static, and dynamically generating it
like this results in a lot of rendering calls. %>
<% cache 'advanced_search' do %>
<div class="container advanced-search">
<div class="width-wrapper">
<h5>Advanced Search: <span>add additional search queries<span></h5>
<% Notice::SEARCHABLE_FIELDS.each do |field| %>
<%= render field %>
<% end %>
<a id="duplicate-field" href="javascript:void(0);" class="add-group">Add more</a>
<div class="resubmit">
<button class="button">Advanced Search</button>
</div>
<div class="container advanced-search">
<div class="width-wrapper">
<h5>Advanced Search: <span>add additional search queries<span></h5>
<% Notice::SEARCHABLE_FIELDS.each do |field| %>
<%= render field %>
<% end %>
<a id="duplicate-field" href="javascript:void(0);" class="add-group">Add more</a>
<div class="resubmit">
<button class="button">Advanced Search</button>
</div>
</div>
<% end %>
</div>
<%= hidden_field_tag(:sort_by, params[:sort_by], class: 'sort_by_field') %>
<% end %>
</div>
Expand Down
37 changes: 37 additions & 0 deletions spec/integration/notice_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,43 @@
expect { submit_search('') }.not_to raise_error
end

scenario 'cache does not break date filter', cache: true do
last_year = Time.at(
Time.now.beginning_of_day - 12.months
).to_datetime.to_s(:simple)
last_month = Time.at(
Time.now.beginning_of_day - 1.month
).to_datetime.to_s(:simple)

create(:dmca, title: 'Ancient History', date_received: 100.days.ago)
create(:dmca, title: 'Modern History', date_received: 1.day.ago)
index_changed_instances

search_for(term: 'history')
expect(
find('a', text: "Since #{last_year}").find('span').text
).to eq '2 Results'
expect(
find('a', text: "Since #{last_month}").find('span').text
).to eq '1 Results'

search_for(term: 'ancient')
expect(
find('a', text: "Since #{last_year}").find('span').text
).to eq '1 Results'
expect(
find('a', text: "Since #{last_month}").find('span').text
).to eq '0 Results'

search_for(term: 'modern')
expect(
find('a', text: "Since #{last_year}").find('span').text
).to eq '1 Results'
expect(
find('a', text: "Since #{last_month}").find('span').text
).to eq '1 Results'
end

private

def expect_search_to_not_find(term, notice)
Expand Down
19 changes: 0 additions & 19 deletions spec/support/matchers/facet_with_value.rb

This file was deleted.