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)
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2015  Jean-Philippe Lang
2
# Copyright (C) 2006-2014  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
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 'last_week'
45
          1.week.ago
46
        when 'last_month'
47
          1.month.ago
48
        when 'last_year'
49
          1.year.ago
50
        else
51
          nil
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)
1 1
# encoding: utf-8
2 2
#
3 3
# Redmine - project management software
4
# Copyright (C) 2006-2015  Jean-Philippe Lang
4
# Copyright (C) 2006-2014  Jean-Philippe Lang
5 5
#
6 6
# This program is free software; you can redistribute it and/or
7 7
# modify it under the terms of the GNU General Public License
......
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)
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2015  Jean-Philippe Lang
2
# Copyright (C) 2006-2014  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
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])
(1-1/3)