Patch #19108 » date_limit_search_2.diff
app/controllers/search_controller.rb (working copy) | ||
---|---|---|
39 | 39 |
offset = nil |
40 | 40 |
begin; offset = params[:offset].to_time if params[:offset]; rescue; end |
41 | 41 | |
42 |
after = |
|
43 |
case params[:after] |
|
44 |
when 'all' |
|
45 |
nil |
|
46 |
when 'last_week' |
|
47 |
1.week.ago |
|
48 |
when 'last_month' |
|
49 |
1.month.ago |
|
50 |
else |
|
51 |
1.year.ago |
|
52 |
end |
|
53 | ||
42 | 54 |
# quick jump to an issue |
43 | 55 |
if (m = @question.match(/^#?(\d+)$/)) && (issue = Issue.visible.find_by_id(m[1].to_i)) |
44 | 56 |
redirect_to issue_path(issue) |
... | ... | |
76 | 88 |
:titles_only => @titles_only, |
77 | 89 |
:limit => (limit+1), |
78 | 90 |
:offset => offset, |
91 |
:after => after, |
|
79 | 92 |
:before => params[:previous].nil?) |
80 | 93 |
@results += r |
81 | 94 |
@results_by_type[s] += c |
app/helpers/search_helper.rb (working copy) | ||
---|---|---|
53 | 53 |
select_tag('scope', options_for_select(options, params[:scope].to_s)) if options.size > 1 |
54 | 54 |
end |
55 | 55 | |
56 |
def time_ago_select_tag |
|
57 |
options = [[t('label_last_week').capitalize, 'last_week']] |
|
58 |
options << [t('label_last_month').capitalize, 'last_month'] |
|
59 |
options << [t('label_last_year').capitalize, 'last_year'] |
|
60 |
options << [t('label_all_time').capitalize, 'all'] |
|
61 |
label_tag('after', l(:description_date_range_list), :class => 'hidden-for-sighted') + |
|
62 |
select_tag('after', options_for_select(options, params[:after] || 'last_year')) |
|
63 |
end |
|
64 | ||
56 | 65 |
def render_results_by_type(results_by_type) |
57 | 66 |
links = [] |
58 | 67 |
# Sorts types by results count |
app/views/search/index.html.erb (working copy) | ||
---|---|---|
5 | 5 |
<%= label_tag "search-input", l(:description_search), :class => "hidden-for-sighted" %> |
6 | 6 |
<p><%= text_field_tag 'q', @question, :size => 60, :id => 'search-input' %> |
7 | 7 |
<%= project_select_tag %> |
8 |
<%= time_ago_select_tag %> |
|
8 | 9 |
<%= hidden_field_tag 'all_words', '', :id => nil %> |
9 | 10 |
<label><%= check_box_tag 'all_words', 1, @all_words %> <%= l(:label_all_words) %></label> |
10 | 11 |
<%= hidden_field_tag 'titles_only', '', :id => nil %> |
config/locales/en.yml (working copy) | ||
---|---|---|
684 | 684 |
label_this_month: this month |
685 | 685 |
label_last_month: last month |
686 | 686 |
label_this_year: this year |
687 |
label_last_year: last year |
|
687 | 688 |
label_date_range: Date range |
688 | 689 |
label_less_than_ago: less than days ago |
689 | 690 |
label_more_than_ago: more than days ago |
lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb (working copy) | ||
---|---|---|
123 | 123 |
where(project_conditions). |
124 | 124 |
where(tokens_conditions) |
125 | 125 | |
126 |
if options[:after] |
|
127 |
scope = scope.where("#{searchable_options[:date_column]} > ?", options[:after]) |
|
128 |
end |
|
129 | ||
126 | 130 |
results_count = scope.count |
127 | 131 | |
128 | 132 |
scope_with_limit = scope.limit(options[:limit]) |
- « Previous
- 1
- 2
- 3
- Next »