Feature #24013 » issue-24013-r16009-keywords.diff
| app/helpers/my_helper.rb | ||
|---|---|---|
|
limit(10).
|
||
|
includes(:status, :project, :tracker, :priority).
|
||
|
references(:status, :project, :tracker, :priority).
|
||
|
order("#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC")
|
||
|
order("#{IssuePriority.table_name}.#{'position'.quote_column_name} DESC, #{Issue.table_name}.updated_on DESC")
|
||
|
end
|
||
|
def issuesreportedbyme_items
|
||
| ... | ... | |
|
joins(:activity, :project).
|
||
|
references(:issue => [:tracker, :status]).
|
||
|
includes(:issue => [:tracker, :status]).
|
||
|
order("#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC").
|
||
|
order("#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.#{'position'.quote_column_name} ASC, #{Issue.table_name}.id ASC").
|
||
|
to_a
|
||
|
return entries, days
|
||
| app/models/enumeration.rb | ||
|---|---|---|
|
super
|
||
|
if position_changed?
|
||
|
self.class.where.not(:parent_id => nil).update_all(
|
||
|
"position = coalesce((
|
||
|
select position
|
||
|
from (select id, position from enumerations) as parent
|
||
|
"#{'position'.quote_column_name} = coalesce((
|
||
|
select #{'position'.quote_column_name}
|
||
|
from (select id, #{'position'.quote_column_name} from enumerations) as parent
|
||
|
where parent_id = parent.id), 1)"
|
||
|
)
|
||
|
end
|
||
| app/models/issue.rb | ||
|---|---|---|
|
if p.priority_derived?
|
||
|
# priority = highest priority of open children
|
||
|
# priority is left unchanged if all children are closed and there's no default priority defined
|
||
|
if priority_position = p.children.open.joins(:priority).maximum("#{IssuePriority.table_name}.position")
|
||
|
if priority_position = p.children.open.joins(:priority).maximum("#{IssuePriority.table_name.quote_table_name}.#{'position'.quote_column_name}")
|
||
|
p.priority = IssuePriority.find_by_position(priority_position)
|
||
|
elsif default_priority = IssuePriority.default
|
||
|
p.priority = default_priority
|
||
| app/models/issue_query.rb | ||
|---|---|---|
|
self.available_columns = [
|
||
|
QueryColumn.new(:id, :sortable => "#{Issue.table_name}.id", :default_order => 'desc', :caption => '#', :frozen => true),
|
||
|
QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true),
|
||
|
QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position", :groupable => true),
|
||
|
QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.#{'position'.quote_column_name}", :groupable => true),
|
||
|
QueryColumn.new(:parent, :sortable => ["#{Issue.table_name}.root_id", "#{Issue.table_name}.lft ASC"], :default_order => 'desc', :caption => :field_parent_issue),
|
||
|
QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position", :groupable => true),
|
||
|
QueryColumn.new(:priority, :sortable => "#{IssuePriority.table_name}.position", :default_order => 'desc', :groupable => true),
|
||
|
QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.#{'position'.quote_column_name}", :groupable => true),
|
||
|
QueryColumn.new(:priority, :sortable => "#{IssuePriority.table_name}.#{'position'.quote_column_name}", :default_order => 'desc', :groupable => true),
|
||
|
QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"),
|
||
|
QueryColumn.new(:author, :sortable => lambda {User.fields_for_order_statement("authors")}, :groupable => true),
|
||
|
QueryColumn.new(:assigned_to, :sortable => lambda {User.fields_for_order_statement}, :groupable => true),
|
||
| app/models/issue_status.rb | ||
|---|---|---|
|
subselect = "SELECT MAX(j.created_on) FROM #{Journal.table_name} j" +
|
||
|
" JOIN #{JournalDetail.table_name} d ON d.journal_id = j.id" +
|
||
|
" WHERE j.journalized_type = 'Issue' AND j.journalized_id = #{Issue.table_name}.id" +
|
||
|
" AND d.property = 'attr' AND d.prop_key = 'status_id' AND d.value = :status_id"
|
||
|
" AND d.property = 'attr' AND d.prop_key = 'status_id' AND d.#{'value'.quote_column_name} = :status_id"
|
||
|
Issue.where(:status_id => id, :closed_on => nil).
|
||
|
update_all(["closed_on = (#{subselect})", {:status_id => id.to_s}])
|
||
| app/models/time_entry_query.rb | ||
|---|---|---|
|
QueryColumn.new(:spent_on, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :default_order => 'desc', :groupable => true),
|
||
|
QueryColumn.new(:tweek, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :caption => l(:label_week)),
|
||
|
QueryColumn.new(:user, :sortable => lambda {User.fields_for_order_statement}, :groupable => true),
|
||
|
QueryColumn.new(:activity, :sortable => "#{TimeEntryActivity.table_name}.position", :groupable => true),
|
||
|
QueryColumn.new(:activity, :sortable => "#{TimeEntryActivity.table_name}.#{'position'.quote_column_name}", :groupable => true),
|
||
|
QueryColumn.new(:issue, :sortable => "#{Issue.table_name}.id"),
|
||
|
QueryAssociationColumn.new(:issue, :tracker, :caption => :field_tracker, :sortable => "#{Tracker.table_name}.position"),
|
||
|
QueryAssociationColumn.new(:issue, :status, :caption => :field_status, :sortable => "#{IssueStatus.table_name}.position"),
|
||
|
QueryAssociationColumn.new(:issue, :tracker, :caption => :field_tracker, :sortable => "#{Tracker.table_name}.#{'position'.quote_column_name}"),
|
||
|
QueryAssociationColumn.new(:issue, :status, :caption => :field_status, :sortable => "#{IssueStatus.table_name}.#{'position'.quote_column_name}"),
|
||
|
QueryColumn.new(:comments),
|
||
|
QueryColumn.new(:hours, :sortable => "#{TimeEntry.table_name}.hours", :totalable => true),
|
||
|
]
|
||
| lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb | ||
|---|---|---|
|
search_scope(user, projects, options).
|
||
|
joins(:custom_values).
|
||
|
where(visibility).
|
||
|
where(search_tokens_condition(["#{CustomValue.table_name}.value"], tokens, options[:all_words])),
|
||
|
where(search_tokens_condition(["#{CustomValue.table_name}.#{'value'.quote_column_name}"], tokens, options[:all_words])),
|
||
|
options[:limit]
|
||
|
)
|
||
|
queries += 1
|
||
| lib/redmine/acts/positioned.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def position_column
|
||
|
'position'.quote_column_name
|
||
|
end
|
||
|
def insert_position
|
||
|
position_scope.where("position >= ? AND id <> ?", position, id).update_all("position = position + 1")
|
||
|
position_scope.where("#{position_column} >= ? AND id <> ?", position, id).update_all("#{position_column} = #{position_column} + 1")
|
||
|
end
|
||
|
def remove_position
|
||
|
position_scope_was.where("position >= ? AND id <> ?", position_was, id).update_all("position = position - 1")
|
||
|
position_scope_was.where("#{position_column} >= ? AND id <> ?", position_was, id).update_all("#{position_column} = #{position_column} - 1")
|
||
|
end
|
||
|
def position_scope_changed?
|
||
| ... | ... | |
|
def shift_positions
|
||
|
offset = position_was <=> position
|
||
|
min, max = [position, position_was].sort
|
||
|
r = position_scope.where("id <> ? AND position BETWEEN ? AND ?", id, min, max).update_all("position = position + #{offset}")
|
||
|
r = position_scope.where("id <> ? AND #{position_column} BETWEEN ? AND ?", id, min, max).update_all("#{position_column} = #{position_column} + #{offset}")
|
||
|
if r != max - min
|
||
|
reset_positions_in_list
|
||
|
end
|
||
| lib/redmine/core_ext/string.rb | ||
|---|---|---|
|
def is_binary_data?
|
||
|
( self.count( "^ -~", "^\r\n" ).fdiv(self.size) > 0.3 || self.index( "\x00" ) ) unless empty?
|
||
|
end
|
||
|
def quote_column_name
|
||
|
ActiveRecord::Base.connection.quote_column_name(self)
|
||
|
end
|
||
|
def quote_table_name
|
||
|
ActiveRecord::Base.connection.quote_table_name(self)
|
||
|
end
|
||
|
end
|
||
| test/unit/query_test.rb | ||
|---|---|---|
|
query = IssueQuery.new(:project => Project.find(1), :name => '_')
|
||
|
query.add_filter('fixed_version_id', '!*', [''])
|
||
|
query.add_filter('cf_1', '!*', [''])
|
||
|
value_col = 'value'.quote_column_name
|
||
|
assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NULL")
|
||
|
assert query.statement.include?("#{CustomValue.table_name}.value IS NULL OR #{CustomValue.table_name}.value = ''")
|
||
|
assert query.statement.include?("#{CustomValue.table_name}.#{value_col} IS NULL OR #{CustomValue.table_name}.#{value_col} = ''")
|
||
|
find_issues_with_query(query)
|
||
|
end
|
||
| ... | ... | |
|
query = IssueQuery.new(:project => Project.find(1), :name => '_')
|
||
|
query.add_filter('fixed_version_id', '*', [''])
|
||
|
query.add_filter('cf_1', '*', [''])
|
||
|
value_col = 'value'.quote_column_name
|
||
|
assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NOT NULL")
|
||
|
assert query.statement.include?("#{CustomValue.table_name}.value IS NOT NULL AND #{CustomValue.table_name}.value <> ''")
|
||
|
assert query.statement.include?("#{CustomValue.table_name}.#{value_col} IS NOT NULL AND #{CustomValue.table_name}.#{value_col} <> ''")
|
||
|
find_issues_with_query(query)
|
||
|
end
|
||