Project

General

Profile

Patch #19108 » DATE_LIMIT_SEARCH.diff

Pierre Pretorius, 2015-02-14 11:30

View differences:

app/controllers/search_controller.rb (working copy)
# Redmine - project management software
# Copyright (C) 2006-2015 Jean-Philippe Lang
# Copyright (C) 2006-2014 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
......
offset = nil
begin; offset = params[:offset].to_time if params[:offset]; rescue; end
after =
case params[:after]
when 'last_week'
1.week.ago
when 'last_month'
1.month.ago
when 'last_year'
1.year.ago
else
nil
end
# quick jump to an issue
if (m = @question.match(/^#?(\d+)$/)) && (issue = Issue.visible.find_by_id(m[1].to_i))
redirect_to issue_path(issue)
......
:titles_only => @titles_only,
:limit => (limit+1),
:offset => offset,
:after => after,
:before => params[:previous].nil?)
@results += r
@results_by_type[s] += c
app/helpers/search_helper.rb (working copy)
# encoding: utf-8
#
# Redmine - project management software
# Copyright (C) 2006-2015 Jean-Philippe Lang
# Copyright (C) 2006-2014 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
......
select_tag('scope', options_for_select(options, params[:scope].to_s)) if options.size > 1
end
def time_ago_select_tag
options = [[t('label_last_week').capitalize, 'last_week']]
options << [t('label_last_month').capitalize, 'last_month']
options << [t('label_last_year').capitalize, 'last_year']
options << [t('label_all_time').capitalize, 'all']
label_tag('after', l(:description_date_range_list), :class => 'hidden-for-sighted') +
select_tag('after', options_for_select(options, params[:after] || 'last_year'))
end
def render_results_by_type(results_by_type)
links = []
# Sorts types by results count
app/views/search/index.html.erb (working copy)
<%= label_tag "search-input", l(:description_search), :class => "hidden-for-sighted" %>
<p><%= text_field_tag 'q', @question, :size => 60, :id => 'search-input' %>
<%= project_select_tag %>
<%= time_ago_select_tag %>
<%= hidden_field_tag 'all_words', '', :id => nil %>
<label><%= check_box_tag 'all_words', 1, @all_words %> <%= l(:label_all_words) %></label>
<%= hidden_field_tag 'titles_only', '', :id => nil %>
config/locales/en.yml (working copy)
label_this_month: this month
label_last_month: last month
label_this_year: this year
label_last_year: last year
label_date_range: Date range
label_less_than_ago: less than days ago
label_more_than_ago: more than days ago
lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb (working copy)
# Redmine - project management software
# Copyright (C) 2006-2015 Jean-Philippe Lang
# Copyright (C) 2006-2014 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
......
where(project_conditions).
where(tokens_conditions)
if options[:after]
scope = scope.where("#{searchable_options[:date_column]} > ?", options[:after])
end
results_count = scope.count
scope_with_limit = scope.limit(options[:limit])
(1-1/3)