Index: app/controllers/search_controller.rb =================================================================== --- app/controllers/search_controller.rb (revision 14003) +++ app/controllers/search_controller.rb (working copy) @@ -1,5 +1,5 @@ # 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 @@ -39,6 +39,18 @@ 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) @@ -76,6 +88,7 @@ :titles_only => @titles_only, :limit => (limit+1), :offset => offset, + :after => after, :before => params[:previous].nil?) @results += r @results_by_type[s] += c Index: app/helpers/search_helper.rb =================================================================== --- app/helpers/search_helper.rb (revision 14003) +++ app/helpers/search_helper.rb (working copy) @@ -1,7 +1,7 @@ # 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 @@ -53,6 +53,15 @@ 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 Index: app/views/search/index.html.erb =================================================================== --- app/views/search/index.html.erb (revision 14003) +++ app/views/search/index.html.erb (working copy) @@ -5,6 +5,7 @@ <%= label_tag "search-input", l(:description_search), :class => "hidden-for-sighted" %>

<%= text_field_tag 'q', @question, :size => 60, :id => 'search-input' %> <%= project_select_tag %> +<%= time_ago_select_tag %> <%= hidden_field_tag 'all_words', '', :id => nil %> <%= hidden_field_tag 'titles_only', '', :id => nil %> Index: config/locales/en.yml =================================================================== --- config/locales/en.yml (revision 14003) +++ config/locales/en.yml (working copy) @@ -684,6 +684,7 @@ 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 Index: lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb =================================================================== --- lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb (revision 14003) +++ lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb (working copy) @@ -1,5 +1,5 @@ # 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 @@ -123,6 +123,10 @@ 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])