Merge branch 'feature_engine_tear_out' of https://dev.finn.de/git/reporting-engine into feature_engine_tear_out

pull/6827/head
jwollert 14 years ago
commit a8c7dd9513
  1. 2
      app/models/report/group_by/base.rb
  2. 34
      app/models/report/operator.rb
  3. 2
      app/models/report/query_utils.rb

@ -27,7 +27,7 @@ class Report::GroupBy
def all_group_fields(prefix = true)
@all_group_fields ||= []
@all_group_fields[prefix ? 0 : 1] ||= begin
fields = group_fields.reject { |c| c.blank? }
fields = group_fields.reject { |c| c.blank? or c == 'base' }
(parent ? parent.all_group_fields(prefix) : []) + (prefix ? with_table(fields) : fields)
end.uniq
end

@ -22,19 +22,19 @@ class Report::Operator
end
def label
@label ||= Query.operators[name]
@label ||= self.class.name.to_sym
end
end
# Operators from Redmine
new ">t-" do
new ">t-", :label => :label_less_than_ago do
include DateRange
def modify(query, field, value)
super query, field, -value.to_i, 0
end
end
new "w", :arity => 0 do
new "w", :arity => 0, :label => :label_this_week do
def modify(query, field, offset = nil)
offset ||= 0
from = Time.now.at_beginning_of_week - ((l(:general_first_day_of_week).to_i % 7) + 1).days
@ -43,16 +43,16 @@ class Report::Operator
end
end
new "t+" do
new "t+", :label => :label_in do
include DateRange
def modify(query, field, *values)
super query, field, values.first.to_i, values.first.to_i
end
end
new "<="
new "<=", :label => :label_less_or_equal
new "!" do
new "!", :label => :label_not_equals do
def modify(query, field, *values)
where_clause = "(#{field} IS NULL"
where_clause += " OR #{field} NOT IN #{collection(*values)}" unless values.compact.empty?
@ -62,14 +62,14 @@ class Report::Operator
end
end
new "t-" do
new "t-", :label => :label_ago do
include DateRange
def modify(query, field, *values)
super query, field, -values.first.to_i, -values.first.to_i
end
end
new "!~", :arity => 1 do
new "!~", :arity => 1, :label => :label_not_contains do
def modify(query, field, *values)
value = values.first || ''
query.where "LOWER(#{field}) NOT LIKE '%#{quote_string(value.to_s.downcase)}%'"
@ -77,7 +77,7 @@ class Report::Operator
end
end
new "=" do
new "=", :label => :label_equals do
def modify(query, field, *values)
if values.compact.empty?
query.where "1=0"
@ -88,7 +88,7 @@ class Report::Operator
end
end
new "~", :arity => 1 do
new "~", :arity => 1, :label => :label_contains do
def modify(query, field, *values)
value = values.first || ''
query.where "LOWER(#{field}) LIKE '%#{quote_string(value.to_s.downcase)}%'"
@ -96,39 +96,39 @@ class Report::Operator
end
end
new "<t+" do
new "<t+", :label => :label_in_less_than do
include DateRange
def modify(query, field, value)
super query, field, 0, value.to_i
end
end
new "t" do
new "t", :label => :label_today do
include DateRange
def modify(query, field)
super query, field, 0, 0
end
end
new ">="
new ">=", :label => :label_greater_or_equal
new "!*", :arity => 0, :where_clause => "%s IS NULL"
new "!*", :arity => 0, :where_clause => "%s IS NULL", :label => :label_none
new "<t-" do
new "<t-", :label => :label_more_than_ago do
include DateRange
def modify(query, field, value)
super query, field, nil, -value.to_i
end
end
new ">t+" do
new ">t+", :label => :label_in_more_than do
include DateRange
def modify(query, field, value)
super query, field, value.to_i, nil
end
end
new "*", :arity => 0, :where_clause => "%s IS NOT NULL"
new "*", :arity => 0, :where_clause => "%s IS NOT NULL", :label => :label_all
# Our own operators
new "<", :label => :label_less

@ -8,7 +8,7 @@ module Report::QueryUtils
# @return [Class] subclass
def engine
return self.class.engine unless is_a? Module
Object.const_get name[/^[^:]+/]
Object.const_get(name[/^[^:]+/] || :Report)
end
##

Loading…
Cancel
Save