##// END OF EJS Templates
Fixed: private subprojects are listed on the issues view (#1217)....
Fixed: private subprojects are listed on the issues view (#1217). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1432 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r1417:9e225cc63ff8
r1417:9e225cc63ff8
Show More
query.rb
369 lines | 15.9 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
"queries" branch merged...
r92 # redMine - project management software
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444 # Copyright (C) 2006-2007 Jean-Philippe Lang
Jean-Philippe Lang
"queries" branch merged...
r92 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 class QueryColumn
Jean-Philippe Lang
More appropriate default sort order on sortable columns....
r1107 attr_accessor :name, :sortable, :default_order
Jean-Philippe Lang
Custom fields can now be displayed as columns on the issue list....
r876 include GLoc
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771
def initialize(name, options={})
self.name = name
self.sortable = options[:sortable]
Jean-Philippe Lang
More appropriate default sort order on sortable columns....
r1107 self.default_order = options[:default_order]
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 end
Jean-Philippe Lang
Custom fields can now be displayed as columns on the issue list....
r876 def caption
Jean-Philippe Lang
Fixed: localization problem on issue list headers....
r893 set_language_if_valid(User.current.language)
Jean-Philippe Lang
Custom fields can now be displayed as columns on the issue list....
r876 l("field_#{name}")
end
end
class QueryCustomFieldColumn < QueryColumn
def initialize(custom_field)
self.name = "cf_#{custom_field.id}".to_sym
self.sortable = false
@cf = custom_field
end
def caption
@cf.name
end
def custom_field
@cf
end
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 end
Jean-Philippe Lang
"queries" branch merged...
r92 class Query < ActiveRecord::Base
belongs_to :project
belongs_to :user
serialize :filters
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 serialize :column_names
Jean-Philippe Lang
"queries" branch merged...
r92
Jean-Philippe Lang
Fix query management broken by r1027....
r1018 attr_protected :project_id, :user_id
Jean-Philippe Lang
"queries" branch merged...
r92
validates_presence_of :name, :on => :save
Jean-Philippe Lang
Added several validates_length_of...
r590 validates_length_of :name, :maximum => 255
Jean-Philippe Lang
"queries" branch merged...
r92
@@operators = { "=" => :label_equals,
"!" => :label_not_equals,
"o" => :label_open_issues,
"c" => :label_closed_issues,
"!*" => :label_none,
"*" => :label_all,
Jean-Philippe Lang
Added "% done" in the filter list....
r710 ">=" => '>=',
"<=" => '<=',
Jean-Philippe Lang
"queries" branch merged...
r92 "<t+" => :label_in_less_than,
">t+" => :label_in_more_than,
"t+" => :label_in,
"t" => :label_today,
Jean-Philippe Lang
Added a new value for date filters: 'this week'...
r693 "w" => :label_this_week,
Jean-Philippe Lang
"queries" branch merged...
r92 ">t-" => :label_less_than_ago,
"<t-" => :label_more_than_ago,
"t-" => :label_ago,
"~" => :label_contains,
"!~" => :label_not_contains }
cattr_reader :operators
@@operators_by_filter_type = { :list => [ "=", "!" ],
:list_status => [ "o", "=", "!", "c", "*" ],
:list_optional => [ "=", "!", "!*", "*" ],
Jean-Philippe Lang
Include subprojects on the issue list, calendar and gantt by default....
r1164 :list_subprojects => [ "*", "!*", "=" ],
Jean-Philippe Lang
Added a new value for date filters: 'this week'...
r693 :date => [ "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-" ],
:date_past => [ ">t-", "<t-", "t-", "t", "w" ],
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444 :string => [ "=", "~", "!", "!~" ],
Jean-Philippe Lang
Added "% done" in the filter list....
r710 :text => [ "~", "!~" ],
:integer => [ "=", ">=", "<=" ] }
Jean-Philippe Lang
"queries" branch merged...
r92
cattr_reader :operators_by_filter_type
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 @@available_columns = [
Jean-Philippe Lang
Default columns displayed on the issue list can now be selected at application level....
r774 QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position"),
QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position"),
Jean-Philippe Lang
More appropriate default sort order on sortable columns....
r1107 QueryColumn.new(:priority, :sortable => "#{Enumeration.table_name}.position", :default_order => 'desc'),
QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"),
Jean-Philippe Lang
Add 'Author' to the available columns for the issue list....
r1096 QueryColumn.new(:author),
Jean-Philippe Lang
Default columns displayed on the issue list can now be selected at application level....
r774 QueryColumn.new(:assigned_to, :sortable => "#{User.table_name}.lastname"),
Jean-Philippe Lang
More appropriate default sort order on sortable columns....
r1107 QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'),
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name"),
Jean-Philippe Lang
Allow issue list to be sorted by target version (#832)....
r1249 QueryColumn.new(:fixed_version, :sortable => "#{Version.table_name}.effective_date", :default_order => 'desc'),
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"),
QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"),
QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"),
QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio"),
Jean-Philippe Lang
More appropriate default sort order on sortable columns....
r1107 QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 ]
cattr_reader :available_columns
Jean-Philippe Lang
"queries" branch merged...
r92 def initialize(attributes = nil)
super attributes
self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} }
Jean-Philippe Lang
Fixed: 'assigned to me' filter broken....
r966 set_language_if_valid(User.current.language)
Jean-Philippe Lang
"me" value is now available in queries for "assigned to" and "author" filters....
r517 end
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 def after_initialize
# Store the fact that project is nil (used in #editable_by?)
@is_for_all = project.nil?
end
Jean-Philippe Lang
"queries" branch merged...
r92 def validate
filters.each_key do |field|
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444 errors.add label_for(field), :activerecord_error_blank unless
Jean-Philippe Lang
"queries" branch merged...
r92 # filter requires one or more values
Jean-Philippe Lang
Fixed: Search for target version of "none" fails with postgres 8.3 (#1134)....
r1364 (values_for(field) and !values_for(field).first.blank?) or
Jean-Philippe Lang
"queries" branch merged...
r92 # filter doesn't require any value
Jean-Philippe Lang
Added a new value for date filters: 'this week'...
r693 ["o", "c", "!*", "*", "t", "w"].include? operator_for(field)
Jean-Philippe Lang
"queries" branch merged...
r92 end if filters
end
Jean-Philippe Lang
Added per user custom queries....
r563 def editable_by?(user)
return false unless user
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 # Admin can edit them all and regular users can edit their private queries
return true if user.admin? || (!is_public && self.user_id == user.id)
# Members can not edit public queries that are for all project (only admin is allowed to)
is_public && !@is_for_all && user.allowed_to?(:manage_public_queries, project)
Jean-Philippe Lang
Added per user custom queries....
r563 end
Jean-Philippe Lang
"queries" branch merged...
r92 def available_filters
return @available_filters if @available_filters
Jean-Philippe Lang
On the calendar, the gantt and in the Tracker filter on the issue list, only active trackers of the project (and its sub projects) can be selected....
r1057
trackers = project.nil? ? Tracker.find(:all, :order => 'position') : project.rolled_up_trackers
Jean-Philippe Lang
added the ability to set the sort order for issue statuses...
r202 @available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } },
Jean-Philippe Lang
On the calendar, the gantt and in the Tracker filter on the issue list, only active trackers of the project (and its sub projects) can be selected....
r1057 "tracker_id" => { :type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] } },
Jean-Philippe Lang
Fixed: Priorities not ordered when displayed as a filter in issue list (#956)....
r1294 "priority_id" => { :type => :list, :order => 3, :values => Enumeration.find(:all, :conditions => ['opt=?','IPRI'], :order => 'position').collect{|s| [s.name, s.id.to_s] } },
Jean-Philippe Lang
added back "fixed version" in issue/show and filters...
r162 "subject" => { :type => :text, :order => 8 },
"created_on" => { :type => :date_past, :order => 9 },
"updated_on" => { :type => :date_past, :order => 10 },
"start_date" => { :type => :date, :order => 11 },
Jean-Philippe Lang
Added "% done" in the filter list....
r710 "due_date" => { :type => :date, :order => 12 },
"done_ratio" => { :type => :integer, :order => 13 }}
Jean-Philippe Lang
Added a cross-project issue list. It displays the issues of all the projects visible by the user....
r673
user_values = []
Jean-Philippe Lang
Fixed: 'assigned to me' filter broken....
r966 user_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
Jean-Philippe Lang
Added a cross-project issue list. It displays the issues of all the projects visible by the user....
r673 if project
Jean-Philippe Lang
'Assigned to' drop down list is now sorted by user's lastname....
r926 user_values += project.users.sort.collect{|s| [s.name, s.id.to_s] }
Jean-Philippe Lang
Fixed: 'assigned to me' filter broken....
r966 else
Jean-Philippe Lang
Added a cross-project issue list. It displays the issues of all the projects visible by the user....
r673 # members of the user's projects
Jean-Philippe Lang
Fixed: 'assigned to me' filter broken....
r966 user_values += User.current.projects.collect(&:users).flatten.uniq.sort.collect{|s| [s.name, s.id.to_s] }
Jean-Philippe Lang
Added a cross-project issue list. It displays the issues of all the projects visible by the user....
r673 end
@available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } unless user_values.empty?
@available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty?
if project
# project specific filters
Jean-Philippe Lang
"queries" branch merged...
r92 @available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
Jean-Philippe Lang
Versions can now be created with no date....
r533 @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } }
Jean-Philippe Lang
Added the ability to archive projects:...
r546 unless @project.active_children.empty?
Jean-Philippe Lang
Include subprojects on the issue list, calendar and gantt by default....
r1164 @available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } }
Jean-Philippe Lang
added back "subproject" filter on issue list...
r347 end
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444 @project.all_custom_fields.select(&:is_filter?).each do |field|
case field.field_format
when "text"
options = { :type => :text, :order => 20 }
when "list"
options = { :type => :list_optional, :values => field.possible_values, :order => 20}
when "date"
options = { :type => :date, :order => 20 }
when "bool"
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
Jean-Philippe Lang
* Fixed: Error when displaying the issue list if a float custom field is marked as 'used as filter'...
r908 else
options = { :type => :string, :order => 20 }
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444 end
@available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
end
Jean-Philippe Lang
"queries" branch merged...
r92 # remove category filter if no category defined
@available_filters.delete "category_id" if @available_filters["category_id"][:values].empty?
end
@available_filters
end
def add_filter(field, operator, values)
# values must be an array
return unless values and values.is_a? Array # and !values.first.empty?
# check if field is defined as an available filter
if available_filters.has_key? field
filter_options = available_filters[field]
# check if operator is allowed for that filter
#if @@operators_by_filter_type[filter_options[:type]].include? operator
# allowed_values = values & ([""] + (filter_options[:values] || []).collect {|val| val[1]})
# filters[field] = {:operator => operator, :values => allowed_values } if (allowed_values.first and !allowed_values.first.empty?) or ["o", "c", "!*", "*", "t"].include? operator
#end
filters[field] = {:operator => operator, :values => values }
end
end
def add_short_filter(field, expression)
return unless expression
parms = expression.scan(/^(o|c|\!|\*)?(.*)$/).first
add_filter field, (parms[0] || "="), [parms[1] || ""]
end
def has_filter?(field)
filters and filters[field]
end
def operator_for(field)
has_filter?(field) ? filters[field][:operator] : nil
end
def values_for(field)
has_filter?(field) ? filters[field][:values] : nil
end
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444 def label_for(field)
label = @available_filters[field][:name] if @available_filters.has_key?(field)
label ||= field.gsub(/\_id$/, "")
end
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771
def available_columns
Jean-Philippe Lang
Custom fields can now be displayed as columns on the issue list....
r876 return @available_columns if @available_columns
@available_columns = Query.available_columns
@available_columns += (project ?
Jean-Philippe Lang
Fixed: issue queries can not use custom fields marked as 'for all projects' in a project context....
r1053 project.all_custom_fields :
Jean-Philippe Lang
Custom fields can now be displayed as columns on the issue list....
r876 IssueCustomField.find(:all, :conditions => {:is_for_all => true})
).collect {|cf| QueryCustomFieldColumn.new(cf) }
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 end
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 def columns
Jean-Philippe Lang
Added a checkbox on custom query form to explicitly say if the query uses default columns or not....
r772 if has_default_columns?
Jean-Philippe Lang
Default columns displayed on the issue list can now be selected at application level....
r774 available_columns.select {|c| Setting.issue_list_default_columns.include?(c.name.to_s) }
Jean-Philippe Lang
Added a checkbox on custom query form to explicitly say if the query uses default columns or not....
r772 else
Jean-Philippe Lang
Custom query columns: checkboxes replaced by two selects that let the user specify columns order....
r773 # preserve the column_names order
column_names.collect {|name| available_columns.find {|col| col.name == name}}.compact
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 end
end
def column_names=(names)
names = names.select {|n| n.is_a?(Symbol) || !n.blank? } if names
names = names.collect {|n| n.is_a?(Symbol) ? n : n.to_sym } if names
write_attribute(:column_names, names)
end
def has_column?(column)
column_names && column_names.include?(column.name)
end
Jean-Philippe Lang
Added a checkbox on custom query form to explicitly say if the query uses default columns or not....
r772
def has_default_columns?
column_names.nil? || column_names.empty?
end
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771
Jean-Philippe Lang
"queries" branch merged...
r92 def statement
Jean-Philippe Lang
Fixed: queries with multiple custom fields return no result....
r662 # project/subprojects clause
Jean-Philippe Lang
Fixed: private subprojects are listed on the issues view (#1217)....
r1417 project_clauses = []
Jean-Philippe Lang
Include subprojects on the issue list, calendar and gantt by default....
r1164 if project && !@project.active_children.empty?
ids = [project.id]
Jean-Philippe Lang
Adds an application setting to choose whether or not subprojects issues should be displayed by default on the issue list, calendar and gantt (r1178). Default is true....
r1184 if has_filter?("subproject_id")
case operator_for("subproject_id")
when '='
# include the selected subprojects
ids += values_for("subproject_id").each(&:to_i)
when '!*'
# main project only
else
# all subprojects
Jean-Philippe Lang
Fixed: private subprojects are listed on the issues view (#1217)....
r1417 ids += project.child_ids
Jean-Philippe Lang
Adds an application setting to choose whether or not subprojects issues should be displayed by default on the issue list, calendar and gantt (r1178). Default is true....
r1184 end
elsif Setting.display_subprojects_issues?
Jean-Philippe Lang
Fixed: private subprojects are listed on the issues view (#1217)....
r1417 ids += project.child_ids
Jean-Philippe Lang
added back "subproject" filter on issue list...
r347 end
Jean-Philippe Lang
Fixed: private subprojects are listed on the issues view (#1217)....
r1417 project_clauses << "#{Issue.table_name}.project_id IN (%s)" % ids.join(',')
Jean-Philippe Lang
Added a cross-project issue list. It displays the issues of all the projects visible by the user....
r673 elsif project
Jean-Philippe Lang
Fixed: private subprojects are listed on the issues view (#1217)....
r1417 project_clauses << "#{Issue.table_name}.project_id = %d" % project.id
Jean-Philippe Lang
added back "subproject" filter on issue list...
r347 end
Jean-Philippe Lang
Fixed: private subprojects are listed on the issues view (#1217)....
r1417 project_clauses << Project.visible_by(User.current)
Jean-Philippe Lang
Fixed: queries with multiple custom fields return no result....
r662
# filters clauses
filters_clauses = []
Jean-Philippe Lang
"queries" branch merged...
r92 filters.each_key do |field|
Jean-Philippe Lang
added back "subproject" filter on issue list...
r347 next if field == "subproject_id"
Jean-Philippe Lang
"me" value is now available in queries for "assigned to" and "author" filters....
r517 v = values_for(field).clone
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444 next unless v and !v.empty?
Jean-Philippe Lang
Fixed: queries with multiple custom fields return no result....
r662
Jean-Philippe Lang
Fixed: Search for target version of "none" fails with postgres 8.3 (#1134)....
r1364 sql = ''
is_custom_filter = false
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444 if field =~ /^cf_(\d+)$/
# custom field
db_table = CustomValue.table_name
Jean-Philippe Lang
Fixed: queries with multiple custom fields return no result....
r662 db_field = 'value'
Jean-Philippe Lang
Fixed: Search for target version of "none" fails with postgres 8.3 (#1134)....
r1364 is_custom_filter = true
Jean-Philippe Lang
Fixes custom field filters behaviour (#1078)....
r1347 sql << "#{Issue.table_name}.id IN (SELECT #{Issue.table_name}.id FROM #{Issue.table_name} LEFT OUTER JOIN #{db_table} ON #{db_table}.customized_type='Issue' AND #{db_table}.customized_id=#{Issue.table_name}.id AND #{db_table}.custom_field_id=#{$1} WHERE "
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444 else
# regular field
db_table = Issue.table_name
db_field = field
Jean-Philippe Lang
Fixed: queries with multiple custom fields return no result....
r662 sql << '('
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444 end
Jean-Philippe Lang
"me" value is now available in queries for "assigned to" and "author" filters....
r517 # "me" value subsitution
if %w(assigned_to_id author_id).include?(field)
Jean-Philippe Lang
Fixed: 'assigned to me' filter broken....
r966 v.push(User.current.logged? ? User.current.id.to_s : "0") if v.delete("me")
Jean-Philippe Lang
"me" value is now available in queries for "assigned to" and "author" filters....
r517 end
Jean-Philippe Lang
"queries" branch merged...
r92 case operator_for field
when "="
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444 sql = sql + "#{db_table}.#{db_field} IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")"
Jean-Philippe Lang
"queries" branch merged...
r92 when "!"
Jean-Philippe Lang
Fixed: Incorrect filtering for unset values when using 'is not' filter....
r1084 sql = sql + "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))"
Jean-Philippe Lang
"queries" branch merged...
r92 when "!*"
Jean-Philippe Lang
Fixed: Search for target version of "none" fails with postgres 8.3 (#1134)....
r1364 sql = sql + "#{db_table}.#{db_field} IS NULL"
sql << " OR #{db_table}.#{db_field} = ''" if is_custom_filter
Jean-Philippe Lang
"queries" branch merged...
r92 when "*"
Jean-Philippe Lang
Fixed: Search for target version of "none" fails with postgres 8.3 (#1134)....
r1364 sql = sql + "#{db_table}.#{db_field} IS NOT NULL"
sql << " AND #{db_table}.#{db_field} <> ''" if is_custom_filter
Jean-Philippe Lang
Added "% done" in the filter list....
r710 when ">="
sql = sql + "#{db_table}.#{db_field} >= #{v.first.to_i}"
when "<="
sql = sql + "#{db_table}.#{db_field} <= #{v.first.to_i}"
Jean-Philippe Lang
"queries" branch merged...
r92 when "o"
Jean-Philippe Lang
fixed #9308 table_name pre/suffix support...
r334 sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id"
Jean-Philippe Lang
"queries" branch merged...
r92 when "c"
Jean-Philippe Lang
fixed #9308 table_name pre/suffix support...
r334 sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}" if field == "status_id"
Jean-Philippe Lang
"queries" branch merged...
r92 when ">t-"
Jean-Philippe Lang
Fixed date query filters (wrong results and sql error with postgresql)...
r551 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today + 1).to_time)]
Jean-Philippe Lang
"queries" branch merged...
r92 when "<t-"
Jean-Philippe Lang
Fixed date query filters (wrong results and sql error with postgresql)...
r551 sql = sql + "#{db_table}.#{db_field} <= '%s'" % connection.quoted_date((Date.today - v.first.to_i).to_time)
Jean-Philippe Lang
"queries" branch merged...
r92 when "t-"
Jean-Philippe Lang
Fixed date query filters (wrong results and sql error with postgresql)...
r551 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today - v.first.to_i + 1).to_time)]
Jean-Philippe Lang
"queries" branch merged...
r92 when ">t+"
Jean-Philippe Lang
Fixed date query filters (wrong results and sql error with postgresql)...
r551 sql = sql + "#{db_table}.#{db_field} >= '%s'" % connection.quoted_date((Date.today + v.first.to_i).to_time)
Jean-Philippe Lang
"queries" branch merged...
r92 when "<t+"
Jean-Philippe Lang
Fixed date query filters (wrong results and sql error with postgresql)...
r551 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)]
Jean-Philippe Lang
"queries" branch merged...
r92 when "t+"
Jean-Philippe Lang
Fixed date query filters (wrong results and sql error with postgresql)...
r551 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today + v.first.to_i).to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)]
Jean-Philippe Lang
"queries" branch merged...
r92 when "t"
Jean-Philippe Lang
Fixed date query filters (wrong results and sql error with postgresql)...
r551 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today+1).to_time)]
Jean-Philippe Lang
Added a new value for date filters: 'this week'...
r693 when "w"
Jean-Philippe Lang
Fixed: 'This week' condition in filter consider monday as the first day of the week even if language sets otherwise (closes #913)....
r1276 from = l(:general_first_day_of_week) == '7' ?
# week starts on sunday
((Date.today.cwday == 7) ? Time.now.at_beginning_of_day : Time.now.at_beginning_of_week - 1.day) :
# week starts on monday (Rails default)
Time.now.at_beginning_of_week
sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)]
Jean-Philippe Lang
"queries" branch merged...
r92 when "~"
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444 sql = sql + "#{db_table}.#{db_field} LIKE '%#{connection.quote_string(v.first)}%'"
Jean-Philippe Lang
"queries" branch merged...
r92 when "!~"
Jean-Philippe Lang
Custom fields for issues can now be used as filters on issue list....
r444 sql = sql + "#{db_table}.#{db_field} NOT LIKE '%#{connection.quote_string(v.first)}%'"
Jean-Philippe Lang
"queries" branch merged...
r92 end
Jean-Philippe Lang
Fixed: queries with multiple custom fields return no result....
r662 sql << ')'
filters_clauses << sql
Jean-Philippe Lang
"queries" branch merged...
r92 end if filters and valid?
Jean-Philippe Lang
Fixed: queries with multiple custom fields return no result....
r662
Jean-Philippe Lang
Fixed: private subprojects are listed on the issues view (#1217)....
r1417 (project_clauses + filters_clauses).join(' AND ')
Jean-Philippe Lang
"queries" branch merged...
r92 end
end