Class: Uberbringer::QueryBase
- Inherits:
-
Array
- Object
- Array
- Uberbringer::QueryBase
show all
- Includes:
- DateHelper
- Defined in:
- lib/uberbringer/query_base.rb
Constant Summary
collapse
- FIELD_MAPPINGS =
{
:status => 'Status',
:submit_date => 'Submit Date',
:group => 'Assigned Group',
:closed_date => 'Closed Date'
}
- STATUS_MAPPINGS =
{
:pending => 'Pending',
:assigned => 'Assigned',
:new => 'New',
:in_progress => 'In Progress',
:closed => 'Closed',
:resolved => 'Resolved'
}
- OPERATORS =
{
:greater_than => '>',
:less_than => '<',
:not_equal_to => '!=',
:equal_to => '='
}
Instance Method Summary
collapse
Methods included from DateHelper
#sunday_before_last, #this_past_sunday, #today
Instance Method Details
#all_closed_tickets ⇒ Object
32
33
34
|
# File 'lib/uberbringer/query_base.rb', line 32
def all_closed_tickets
filter_by_status([STATUS_MAPPINGS[:closed]])
end
|
#all_open_tickets ⇒ Object
#closed_last_week ⇒ Object
44
45
46
47
|
# File 'lib/uberbringer/query_base.rb', line 44
def closed_last_week
self << {:field => FIELD_MAPPINGS[:closed_date], :value => date_format(sunday_before_last), :operator => OPERATORS[:greater_than]}
self << {:field => FIELD_MAPPINGS[:closed_date], :value => date_format(this_past_sunday), :operator => OPERATORS[:less_than]}
end
|
#closed_this_week ⇒ Object
40
41
42
|
# File 'lib/uberbringer/query_base.rb', line 40
def closed_this_week
self << {:field => FIELD_MAPPINGS[:closed_date], :value => date_format(this_past_sunday), :operator => OPERATORS[:greater_than]}
end
|
#closed_within_days(number_of_days = 7) ⇒ Object
67
68
69
|
# File 'lib/uberbringer/query_base.rb', line 67
def closed_within_days(number_of_days = 7)
self << {:field => FIELD_MAPPINGS[:closed_date], :value => date_format(Date.today - number_of_days), :operator => OPERATORS[:greater_than]}
end
|
#for_group(group) ⇒ Object
53
54
55
|
# File 'lib/uberbringer/query_base.rb', line 53
def for_group(group)
self << {:field => FIELD_MAPPINGS[:group], :value => group}
end
|
#older_than(number_of_days) ⇒ Object
36
37
38
|
# File 'lib/uberbringer/query_base.rb', line 36
def older_than(number_of_days)
self << {:field => FIELD_MAPPINGS[:submit_date], :value => date_format(Date.today - number_of_days), :operator => OPERATORS[:less_than]}
end
|
#submitted_today ⇒ Object
49
50
51
|
# File 'lib/uberbringer/query_base.rb', line 49
def submitted_today
self << {:field => FIELD_MAPPINGS[:submit_date], :value => date_format(today), :operator => OPERATORS[:greater_than]}
end
|
#with_status(status) ⇒ Object
57
58
59
60
|
# File 'lib/uberbringer/query_base.rb', line 57
def with_status(status)
raise ArgumentError unless status.kind_of?(Array)
filter_by_status(map_status(status))
end
|
#without_status(status) ⇒ Object
62
63
64
65
|
# File 'lib/uberbringer/query_base.rb', line 62
def without_status(status)
raise ArgumentError unless status.kind_of?(Array)
filter_by_status(map_status(status),OPERATORS[:not_equal_to])
end
|