Fixed issue #2089 - timezone issue with report graphs not displaying or displaying $timezone hours out of step.
This commit is contained in:
parent
a1bb61bf56
commit
f72b44234e
22 changed files with 730 additions and 480 deletions
|
@ -186,7 +186,7 @@ class Graph extends App.ControllerContent
|
||||||
xaxis.push [minute, '']
|
xaxis.push [minute, '']
|
||||||
else if @params.timeRange is 'day'
|
else if @params.timeRange is 'day'
|
||||||
for hour in [0..23]
|
for hour in [0..23]
|
||||||
xaxis.push [hour, hour+1]
|
xaxis.push [hour, hour]
|
||||||
else if @params.timeRange is 'month'
|
else if @params.timeRange is 'month'
|
||||||
for day in [0..30]
|
for day in [0..30]
|
||||||
xaxis.push [day, day+1]
|
xaxis.push [day, day+1]
|
||||||
|
|
|
@ -37,24 +37,11 @@ class ReportsController < ApplicationController
|
||||||
interval: get_params[:range],
|
interval: get_params[:range],
|
||||||
selector: backend[:condition],
|
selector: backend[:condition],
|
||||||
params: backend[:params],
|
params: backend[:params],
|
||||||
|
timezone: get_params[:timezone],
|
||||||
|
timezone_offset: get_params[:timezone_offset],
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
#created = aggs(start, stop, range, 'created_at', profile.condition)
|
|
||||||
#closed = aggs(start, stop, range, 'close_at', profile.condition)
|
|
||||||
#first_solution =
|
|
||||||
#reopend = backend(start, stop, range, Report::TicketReopened, profile.condition)
|
|
||||||
|
|
||||||
# add backlog
|
|
||||||
#backlogs = []
|
|
||||||
#position = -1
|
|
||||||
#created.each {|_not_used|
|
|
||||||
# position += 1
|
|
||||||
# diff = created[position][1] - closed[position][1]
|
|
||||||
# backlog = [position+1, diff]
|
|
||||||
# backlogs.push backlog
|
|
||||||
#}
|
|
||||||
|
|
||||||
render json: {
|
render json: {
|
||||||
data: result
|
data: result
|
||||||
}
|
}
|
||||||
|
@ -92,6 +79,8 @@ class ReportsController < ApplicationController
|
||||||
selector: backend[:condition],
|
selector: backend[:condition],
|
||||||
params: backend[:params],
|
params: backend[:params],
|
||||||
sheet: params[:sheet],
|
sheet: params[:sheet],
|
||||||
|
timezone: get_params[:timezone],
|
||||||
|
timezone_offset: get_params[:timezone_offset],
|
||||||
)
|
)
|
||||||
|
|
||||||
result = { count: 0, ticket_ids: [] } if result.nil?
|
result = { count: 0, ticket_ids: [] } if result.nil?
|
||||||
|
@ -138,36 +127,46 @@ class ReportsController < ApplicationController
|
||||||
|
|
||||||
metric = local_config[:metric][params[:metric].to_sym]
|
metric = local_config[:metric][params[:metric].to_sym]
|
||||||
|
|
||||||
#{"metric"=>"count", "year"=>2015, "month"=>10, "week"=>43, "day"=>20, "timeSlot"=>"year", "report"=>{"metric"=>"count", "year"=>2015, "month"=>10, "week"=>43, "day"=>20, "timeSlot"=>"year"}}
|
|
||||||
if params[:timeRange] == 'realtime'
|
if params[:timeRange] == 'realtime'
|
||||||
start = (Time.zone.now - 60.minutes).iso8601
|
start_at = (Time.zone.now - 60.minutes)
|
||||||
stop = Time.zone.now.iso8601
|
stop_at = Time.zone.now
|
||||||
range = 'minute'
|
range = 'minute'
|
||||||
elsif params[:timeRange] == 'day'
|
elsif params[:timeRange] == 'day'
|
||||||
date = Date.parse("#{params[:year]}-#{params[:month]}-#{params[:day]}").to_s
|
date = Date.parse("#{params[:year]}-#{params[:month]}-#{params[:day]}").to_s
|
||||||
start = "#{date}T00:00:00Z"
|
start_at = Time.zone.parse("#{date}T00:00:00Z")
|
||||||
stop = "#{date}T23:59:59Z"
|
stop_at = Time.zone.parse("#{date}T23:59:59Z")
|
||||||
range = 'hour'
|
range = 'hour'
|
||||||
elsif params[:timeRange] == 'week'
|
elsif params[:timeRange] == 'week'
|
||||||
start = Date.commercial(params[:year].to_i, params[:week].to_i).iso8601
|
start_week_at = Date.commercial(params[:year].to_i, params[:week].to_i)
|
||||||
stop = Date.parse(start).end_of_week.iso8601
|
stop_week_at = start_week_at.end_of_week
|
||||||
|
start_at = Time.zone.parse("#{start_week_at.year}-#{start_week_at.month}-#{start_week_at.day}T00:00:00Z")
|
||||||
|
stop_at = Time.zone.parse("#{stop_week_at.year}-#{stop_week_at.month}-#{stop_week_at.day}T23:59:59Z")
|
||||||
range = 'week'
|
range = 'week'
|
||||||
elsif params[:timeRange] == 'month'
|
elsif params[:timeRange] == 'month'
|
||||||
start = Date.parse("#{params[:year]}-#{params[:month]}-01}").iso8601
|
start_at = Time.zone.parse("#{params[:year]}-#{params[:month]}-01T00:00:00Z")
|
||||||
stop = Date.parse(start).end_of_month.iso8601
|
stop_at = Time.zone.parse("#{params[:year]}-#{params[:month]}-#{start_at.end_of_month.day}T23:59:59Z")
|
||||||
range = 'day'
|
range = 'day'
|
||||||
else
|
else
|
||||||
start = "#{params[:year]}-01-01"
|
start_at = Time.zone.parse("#{params[:year]}-01-01T00:00:00Z")
|
||||||
stop = Date.parse("#{params[:year]}-12-31").iso8601
|
stop_at = Time.zone.parse("#{params[:year]}-12-31T23:59:59Z")
|
||||||
range = 'month'
|
range = 'month'
|
||||||
end
|
end
|
||||||
|
params[:timezone] ||= Setting.get('timezone_default')
|
||||||
|
if params[:timezone].present? && params[:timeRange] != 'realtime'
|
||||||
|
offset = stop_at.in_time_zone(params[:timezone]).utc_offset
|
||||||
|
start_at -= offset
|
||||||
|
stop_at -= offset
|
||||||
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
profile: profile,
|
profile: profile,
|
||||||
metric: metric,
|
metric: metric,
|
||||||
config: local_config,
|
config: local_config,
|
||||||
start: start,
|
start: start_at,
|
||||||
stop: stop,
|
stop: stop_at,
|
||||||
range: range,
|
range: range,
|
||||||
|
timezone: params[:timezone],
|
||||||
|
timezone_offset: offset,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,12 @@ class SearchController < ApplicationController
|
||||||
objects_in_order.push objects_in_order_hash[prio]
|
objects_in_order.push objects_in_order_hash[prio]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
generic_search_params = {
|
||||||
|
query: query,
|
||||||
|
limit: limit,
|
||||||
|
current_user: current_user,
|
||||||
|
}
|
||||||
|
|
||||||
# try search index backend
|
# try search index backend
|
||||||
assets = {}
|
assets = {}
|
||||||
result = []
|
result = []
|
||||||
|
@ -76,7 +82,7 @@ class SearchController < ApplicationController
|
||||||
|
|
||||||
# e. g. do ticket query by Ticket class to handle ticket permissions
|
# e. g. do ticket query by Ticket class to handle ticket permissions
|
||||||
objects_without_direct_search_index.each do |object|
|
objects_without_direct_search_index.each do |object|
|
||||||
object_result = search_generic_backend(object.constantize, query, limit, current_user, assets)
|
object_result = search_generic_backend(object.constantize, assets, generic_search_params)
|
||||||
if object_result.present?
|
if object_result.present?
|
||||||
result = result.concat(object_result)
|
result = result.concat(object_result)
|
||||||
end
|
end
|
||||||
|
@ -98,7 +104,7 @@ class SearchController < ApplicationController
|
||||||
|
|
||||||
# do query
|
# do query
|
||||||
objects_in_order.each do |object|
|
objects_in_order.each do |object|
|
||||||
object_result = search_generic_backend(object, query, limit, current_user, assets)
|
object_result = search_generic_backend(object, assets, generic_search_params)
|
||||||
if object_result.present?
|
if object_result.present?
|
||||||
result = result.concat(object_result)
|
result = result.concat(object_result)
|
||||||
end
|
end
|
||||||
|
@ -113,12 +119,22 @@ class SearchController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def search_generic_backend(object, query, limit, current_user, assets)
|
=begin
|
||||||
found_objects = object.search(
|
|
||||||
query: query,
|
search generic backend
|
||||||
limit: limit,
|
|
||||||
current_user: current_user,
|
SearchController#search_generic_backend(
|
||||||
|
Ticket, # object
|
||||||
|
{}, # assets
|
||||||
|
query: "search query",
|
||||||
|
limit: 10,
|
||||||
|
current_user: user,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
def search_generic_backend(object, assets, params)
|
||||||
|
found_objects = object.search(params)
|
||||||
result = []
|
result = []
|
||||||
found_objects.each do |found_object|
|
found_objects.each do |found_object|
|
||||||
item = {
|
item = {
|
||||||
|
|
|
@ -482,7 +482,7 @@ class TicketsController < ApplicationController
|
||||||
def selector
|
def selector
|
||||||
permission_check('admin.*')
|
permission_check('admin.*')
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(params[:condition], 6)
|
ticket_count, tickets = Ticket.selectors(params[:condition], limit: 6)
|
||||||
|
|
||||||
assets = {}
|
assets = {}
|
||||||
ticket_ids = []
|
ticket_ids = []
|
||||||
|
|
|
@ -26,7 +26,7 @@ module ChecksConditionValidation
|
||||||
value: 1,
|
value: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(validate_condition, 1, User.find(1))
|
ticket_count, tickets = Ticket.selectors(validate_condition, limit: 1, current_user: User.find(1))
|
||||||
return true if ticket_count.present?
|
return true if ticket_count.present?
|
||||||
|
|
||||||
raise Exceptions::UnprocessableEntity, 'Invalid ticket selector conditions'
|
raise Exceptions::UnprocessableEntity, 'Invalid ticket selector conditions'
|
||||||
|
|
|
@ -72,7 +72,7 @@ job.run(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
# find tickets to change
|
# find tickets to change
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 2_000)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 2_000)
|
||||||
|
|
||||||
logger.debug { "Job #{name} with #{ticket_count} tickets" }
|
logger.debug { "Job #{name} with #{ticket_count} tickets" }
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ job.run(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def matching_count
|
def matching_count
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 1)
|
||||||
ticket_count || 0
|
ticket_count || 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -424,14 +424,17 @@ returns
|
||||||
|
|
||||||
get count of tickets and tickets which match on selector
|
get count of tickets and tickets which match on selector
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(params[:condition], limit, current_user, 'full')
|
ticket_count, tickets = Ticket.selectors(params[:condition], limit: limit, current_user: current_user, access: 'full')
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.selectors(selectors, limit = 10, current_user = nil, access = 'full')
|
def self.selectors(selectors, options)
|
||||||
|
limit = options[:limit] || 10
|
||||||
|
current_user = options[:current_user]
|
||||||
|
access = options[:access] || 'full'
|
||||||
raise 'no selectors given' if !selectors
|
raise 'no selectors given' if !selectors
|
||||||
|
|
||||||
query, bind_params, tables = selector2sql(selectors, current_user)
|
query, bind_params, tables = selector2sql(selectors, current_user: current_user)
|
||||||
return [] if !query
|
return [] if !query
|
||||||
|
|
||||||
ActiveRecord::Base.transaction(requires_new: true) do
|
ActiveRecord::Base.transaction(requires_new: true) do
|
||||||
|
@ -459,7 +462,7 @@ get count of tickets and tickets which match on selector
|
||||||
|
|
||||||
generate condition query to search for tickets based on condition
|
generate condition query to search for tickets based on condition
|
||||||
|
|
||||||
query_condition, bind_condition, tables = selector2sql(params[:condition], current_user)
|
query_condition, bind_condition, tables = selector2sql(params[:condition], current_user: current_user)
|
||||||
|
|
||||||
condition example
|
condition example
|
||||||
|
|
||||||
|
@ -502,7 +505,8 @@ condition example
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.selector2sql(selectors, current_user = nil)
|
def self.selector2sql(selectors, options = {})
|
||||||
|
current_user = options[:current_user]
|
||||||
current_user_id = UserInfo.current_user_id
|
current_user_id = UserInfo.current_user_id
|
||||||
if current_user
|
if current_user
|
||||||
current_user_id = current_user.id
|
current_user_id = current_user.id
|
||||||
|
@ -1102,7 +1106,7 @@ perform active triggers on ticket
|
||||||
end
|
end
|
||||||
|
|
||||||
# verify is condition is matching
|
# verify is condition is matching
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 1)
|
||||||
|
|
||||||
next if ticket_count.blank?
|
next if ticket_count.blank?
|
||||||
next if ticket_count.zero?
|
next if ticket_count.zero?
|
||||||
|
|
|
@ -87,7 +87,7 @@ returns
|
||||||
ticket_attributes = Ticket.new.attributes
|
ticket_attributes = Ticket.new.attributes
|
||||||
list = []
|
list = []
|
||||||
overviews.each do |overview|
|
overviews.each do |overview|
|
||||||
query_condition, bind_condition, tables = Ticket.selector2sql(overview.condition, user)
|
query_condition, bind_condition, tables = Ticket.selector2sql(overview.condition, current_user: user)
|
||||||
direction = overview.order[:direction]
|
direction = overview.order[:direction]
|
||||||
order_by = overview.order[:by]
|
order_by = overview.order[:by]
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ class Report::ArticleByTypeSender < Report::Base
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
result = Report::ArticleByTypeSender.aggs(
|
result = Report::ArticleByTypeSender.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # quarter, month, week, day, hour, minute, second
|
interval: 'month', # quarter, month, week, day, hour, minute, second
|
||||||
selector: selector, # ticket selector to get only a collection of tickets
|
selector: selector, # ticket selector to get only a collection of tickets
|
||||||
params: {
|
params: {
|
||||||
|
@ -19,7 +19,8 @@ returns
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.aggs(params)
|
def self.aggs(params_origin)
|
||||||
|
params = params_origin.dup
|
||||||
|
|
||||||
interval = params[:interval]
|
interval = params[:interval]
|
||||||
if params[:interval] == 'week'
|
if params[:interval] == 'week'
|
||||||
|
@ -28,32 +29,27 @@ returns
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
if params[:interval] == 'month'
|
if params[:interval] == 'month'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 12
|
stop_interval = 12
|
||||||
elsif params[:interval] == 'week'
|
elsif params[:interval] == 'week'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 7
|
stop_interval = 7
|
||||||
elsif params[:interval] == 'day'
|
elsif params[:interval] == 'day'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 31
|
stop_interval = 31
|
||||||
elsif params[:interval] == 'hour'
|
elsif params[:interval] == 'hour'
|
||||||
start = Time.zone.parse(params[:range_start])
|
|
||||||
stop_interval = 24
|
stop_interval = 24
|
||||||
elsif params[:interval] == 'minute'
|
elsif params[:interval] == 'minute'
|
||||||
start = Time.zone.parse(params[:range_start])
|
|
||||||
stop_interval = 60
|
stop_interval = 60
|
||||||
end
|
end
|
||||||
(1..stop_interval).each do |_counter|
|
(1..stop_interval).each do |_counter|
|
||||||
if params[:interval] == 'month'
|
if params[:interval] == 'month'
|
||||||
stop = start.next_month
|
params[:range_end] = params[:range_start].next_month
|
||||||
elsif params[:interval] == 'week'
|
elsif params[:interval] == 'week'
|
||||||
stop = start.next_day
|
params[:range_end] = params[:range_start].next_day
|
||||||
elsif params[:interval] == 'day'
|
elsif params[:interval] == 'day'
|
||||||
stop = start.next_day
|
params[:range_end] = params[:range_start].next_day
|
||||||
elsif params[:interval] == 'hour'
|
elsif params[:interval] == 'hour'
|
||||||
stop = start + 1.hour
|
params[:range_end] = params[:range_start] + 1.hour
|
||||||
elsif params[:interval] == 'minute'
|
elsif params[:interval] == 'minute'
|
||||||
stop = start + 1.minute
|
params[:range_end] = params[:range_start] + 1.minute
|
||||||
end
|
end
|
||||||
query, bind_params, tables = Ticket.selector2sql(params[:selector])
|
query, bind_params, tables = Ticket.selector2sql(params[:selector])
|
||||||
sender = Ticket::Article::Sender.lookup(name: params[:params][:sender])
|
sender = Ticket::Article::Sender.lookup(name: params[:params][:sender])
|
||||||
|
@ -62,13 +58,13 @@ returns
|
||||||
.where(query, *bind_params).joins(tables)
|
.where(query, *bind_params).joins(tables)
|
||||||
.where(
|
.where(
|
||||||
'ticket_articles.created_at >= ? AND ticket_articles.created_at <= ? AND ticket_articles.type_id = ? AND ticket_articles.sender_id = ?',
|
'ticket_articles.created_at >= ? AND ticket_articles.created_at <= ? AND ticket_articles.type_id = ? AND ticket_articles.sender_id = ?',
|
||||||
start,
|
params[:range_start],
|
||||||
stop,
|
params[:range_end],
|
||||||
type.id,
|
type.id,
|
||||||
sender.id,
|
sender.id,
|
||||||
).count
|
).count
|
||||||
result.push count
|
result.push count
|
||||||
start = stop
|
params[:range_start] = params[:range_end]
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
@ -76,8 +72,8 @@ returns
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
result = Report::ArticleByTypeSender.items(
|
result = Report::ArticleByTypeSender.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: selector, # ticket selector to get only a collection of tickets
|
selector: selector, # ticket selector to get only a collection of tickets
|
||||||
selector: selector, # ticket selector to get only a collection of tickets
|
selector: selector, # ticket selector to get only a collection of tickets
|
||||||
params: {
|
params: {
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Report::Base
|
||||||
|
|
||||||
# created
|
# created
|
||||||
if params[:type] == 'created'
|
if params[:type] == 'created'
|
||||||
history_type = History::Type.lookup( name: 'created' )
|
history_type = History::Type.lookup(name: 'created')
|
||||||
return History.select('histories.o_id').joins('INNER JOIN tickets ON tickets.id = histories.o_id')
|
return History.select('histories.o_id').joins('INNER JOIN tickets ON tickets.id = histories.o_id')
|
||||||
.where(
|
.where(
|
||||||
'histories.created_at >= ? AND histories.created_at <= ? AND histories.history_object_id = ? AND histories.history_type_id = ?', params[:start], params[:end], history_object.id, history_type.id
|
'histories.created_at >= ? AND histories.created_at <= ? AND histories.history_object_id = ? AND histories.history_type_id = ?', params[:start], params[:end], history_object.id, history_type.id
|
||||||
|
@ -26,8 +26,8 @@ class Report::Base
|
||||||
|
|
||||||
# updated
|
# updated
|
||||||
if params[:type] == 'updated'
|
if params[:type] == 'updated'
|
||||||
history_type = History::Type.lookup( name: 'updated' )
|
history_type = History::Type.lookup(name: 'updated')
|
||||||
history_attribute = History::Attribute.lookup( name: params[:attribute] )
|
history_attribute = History::Attribute.lookup(name: params[:attribute])
|
||||||
|
|
||||||
result = nil
|
result = nil
|
||||||
if !history_attribute || !history_type
|
if !history_attribute || !history_type
|
||||||
|
@ -114,7 +114,7 @@ class Report::Base
|
||||||
# :condition
|
# :condition
|
||||||
def self.history(data)
|
def self.history(data)
|
||||||
|
|
||||||
history_object = History::Object.lookup( name: data[:object] )
|
history_object = History::Object.lookup(name: data[:object])
|
||||||
|
|
||||||
query, bind_params, tables = Ticket.selector2sql(data[:selector])
|
query, bind_params, tables = Ticket.selector2sql(data[:selector])
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ class Report::Base
|
||||||
|
|
||||||
# created
|
# created
|
||||||
if data[:type] == 'created'
|
if data[:type] == 'created'
|
||||||
history_type = History::Type.lookup( name: 'created' )
|
history_type = History::Type.lookup(name: 'created')
|
||||||
histories = History.select('histories.o_id').joins('INNER JOIN tickets ON tickets.id = histories.o_id')
|
histories = History.select('histories.o_id').joins('INNER JOIN tickets ON tickets.id = histories.o_id')
|
||||||
.where(
|
.where(
|
||||||
'histories.created_at >= ? AND histories.created_at <= ? AND histories.history_object_id = ? AND histories.history_type_id = ?', data[:start], data[:end], history_object.id, history_type.id
|
'histories.created_at >= ? AND histories.created_at <= ? AND histories.history_object_id = ? AND histories.history_type_id = ?', data[:start], data[:end], history_object.id, history_type.id
|
||||||
|
@ -141,8 +141,8 @@ class Report::Base
|
||||||
|
|
||||||
# updated
|
# updated
|
||||||
if data[:type] == 'updated'
|
if data[:type] == 'updated'
|
||||||
history_type = History::Type.lookup( name: 'updated' )
|
history_type = History::Type.lookup(name: 'updated')
|
||||||
history_attribute = History::Attribute.lookup( name: data[:attribute] )
|
history_attribute = History::Attribute.lookup(name: data[:attribute])
|
||||||
if !history_attribute || !history_type
|
if !history_attribute || !history_type
|
||||||
count = 0
|
count = 0
|
||||||
else
|
else
|
||||||
|
@ -229,7 +229,7 @@ class Report::Base
|
||||||
# :condition
|
# :condition
|
||||||
def self.time_average(data)
|
def self.time_average(data)
|
||||||
query, bind_params, tables = Ticket.selector2sql(data[:condition])
|
query, bind_params, tables = Ticket.selector2sql(data[:condition])
|
||||||
ticket_list = Ticket.where( 'tickets.created_at >= ? AND tickets.created_at <= ?', data[:start], data[:end] )
|
ticket_list = Ticket.where('tickets.created_at >= ? AND tickets.created_at <= ?', data[:start], data[:end])
|
||||||
.where(query, *bind_params).joins(tables)
|
.where(query, *bind_params).joins(tables)
|
||||||
tickets = 0
|
tickets = 0
|
||||||
time_total = 0
|
time_total = 0
|
||||||
|
@ -261,7 +261,7 @@ class Report::Base
|
||||||
# :condition
|
# :condition
|
||||||
def self.time_min(data)
|
def self.time_min(data)
|
||||||
query, bind_params, tables = Ticket.selector2sql(data[:condition])
|
query, bind_params, tables = Ticket.selector2sql(data[:condition])
|
||||||
ticket_list = Ticket.where( 'tickets.created_at >= ? AND tickets.created_at <= ?', data[:start], data[:end] )
|
ticket_list = Ticket.where('tickets.created_at >= ? AND tickets.created_at <= ?', data[:start], data[:end])
|
||||||
.where(query, *bind_params).joins(tables)
|
.where(query, *bind_params).joins(tables)
|
||||||
tickets = 0
|
tickets = 0
|
||||||
time_min = 0
|
time_min = 0
|
||||||
|
@ -299,7 +299,7 @@ class Report::Base
|
||||||
# :condition
|
# :condition
|
||||||
def self.time_max(data)
|
def self.time_max(data)
|
||||||
query, bind_params, tables = Ticket.selector2sql(data[:condition])
|
query, bind_params, tables = Ticket.selector2sql(data[:condition])
|
||||||
ticket_list = Ticket.where( 'tickets.created_at >= ? AND tickets.created_at <= ?', data[:start], data[:end] )
|
ticket_list = Ticket.where('tickets.created_at >= ? AND tickets.created_at <= ?', data[:start], data[:end])
|
||||||
.where(query, *bind_params).joins(tables)
|
.where(query, *bind_params).joins(tables)
|
||||||
tickets = 0
|
tickets = 0
|
||||||
time_max = 0
|
time_max = 0
|
||||||
|
|
|
@ -3,10 +3,11 @@ class Report::TicketBacklog < Report::Base
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
result = Report::TicketBacklog.aggs(
|
result = Report::TicketBacklog.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # quarter, month, week, day, hour, minute, second
|
interval: 'month', # quarter, month, week, day, hour, minute, second
|
||||||
selector: selector, # ticket selector to get only a collection of tickets
|
selector: selector, # ticket selector to get only a collection of tickets
|
||||||
|
timezone: 'Europe/Berlin',
|
||||||
)
|
)
|
||||||
|
|
||||||
returns
|
returns
|
||||||
|
@ -15,7 +16,8 @@ returns
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.aggs(params)
|
def self.aggs(params_origin)
|
||||||
|
params = params_origin.dup
|
||||||
|
|
||||||
local_params = params.clone
|
local_params = params.clone
|
||||||
local_params[:params] = {}
|
local_params[:params] = {}
|
||||||
|
@ -37,8 +39,8 @@ returns
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
result = Report::TicketBacklog.items(
|
result = Report::TicketBacklog.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: selector, # ticket selector to get only a collection of tickets
|
selector: selector, # ticket selector to get only a collection of tickets
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ class Report::TicketFirstSolution
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
result = Report::TicketFirstSolution.aggs(
|
result = Report::TicketFirstSolution.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # quarter, month, week, day, hour, minute, second
|
interval: 'month', # quarter, month, week, day, hour, minute, second
|
||||||
selector: selector, # ticket selector to get only a collection of tickets
|
selector: selector, # ticket selector to get only a collection of tickets
|
||||||
)
|
)
|
||||||
|
@ -15,7 +15,8 @@ returns
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.aggs(params)
|
def self.aggs(params_origin)
|
||||||
|
params = params_origin.dup
|
||||||
interval = params[:interval]
|
interval = params[:interval]
|
||||||
if params[:interval] == 'week'
|
if params[:interval] == 'week'
|
||||||
interval = 'day'
|
interval = 'day'
|
||||||
|
@ -23,32 +24,27 @@ returns
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
if params[:interval] == 'month'
|
if params[:interval] == 'month'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 12
|
stop_interval = 12
|
||||||
elsif params[:interval] == 'week'
|
elsif params[:interval] == 'week'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 7
|
stop_interval = 7
|
||||||
elsif params[:interval] == 'day'
|
elsif params[:interval] == 'day'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 31
|
stop_interval = 31
|
||||||
elsif params[:interval] == 'hour'
|
elsif params[:interval] == 'hour'
|
||||||
start = Time.zone.parse(params[:range_start])
|
|
||||||
stop_interval = 24
|
stop_interval = 24
|
||||||
elsif params[:interval] == 'minute'
|
elsif params[:interval] == 'minute'
|
||||||
start = Time.zone.parse(params[:range_start])
|
|
||||||
stop_interval = 60
|
stop_interval = 60
|
||||||
end
|
end
|
||||||
(1..stop_interval).each do |_counter|
|
(1..stop_interval).each do |_counter|
|
||||||
if params[:interval] == 'month'
|
if params[:interval] == 'month'
|
||||||
stop = start.next_month
|
params[:range_end] = params[:range_start].next_month
|
||||||
elsif params[:interval] == 'week'
|
elsif params[:interval] == 'week'
|
||||||
stop = start.next_day
|
params[:range_end] = params[:range_start].next_day
|
||||||
elsif params[:interval] == 'day'
|
elsif params[:interval] == 'day'
|
||||||
stop = start.next_day
|
params[:range_end] = params[:range_start].next_day
|
||||||
elsif params[:interval] == 'hour'
|
elsif params[:interval] == 'hour'
|
||||||
stop = start + 1.hour
|
params[:range_end] = params[:range_start] + 1.hour
|
||||||
elsif params[:interval] == 'minute'
|
elsif params[:interval] == 'minute'
|
||||||
stop = start + 1.minute
|
params[:range_end] = params[:range_start] + 1.minute
|
||||||
end
|
end
|
||||||
|
|
||||||
without_merged_tickets = {
|
without_merged_tickets = {
|
||||||
|
@ -61,8 +57,8 @@ returns
|
||||||
query, bind_params, tables = Ticket.selector2sql(params[:selector])
|
query, bind_params, tables = Ticket.selector2sql(params[:selector])
|
||||||
ticket_list = Ticket.select('tickets.id, tickets.close_at, tickets.created_at').where(
|
ticket_list = Ticket.select('tickets.id, tickets.close_at, tickets.created_at').where(
|
||||||
'tickets.close_at IS NOT NULL AND tickets.close_at >= ? AND tickets.close_at < ?',
|
'tickets.close_at IS NOT NULL AND tickets.close_at >= ? AND tickets.close_at < ?',
|
||||||
start,
|
params[:range_start],
|
||||||
stop,
|
params[:range_end],
|
||||||
).where(query, *bind_params).joins(tables)
|
).where(query, *bind_params).joins(tables)
|
||||||
count = 0
|
count = 0
|
||||||
ticket_list.each do |ticket|
|
ticket_list.each do |ticket|
|
||||||
|
@ -73,7 +69,7 @@ returns
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
result.push count
|
result.push count
|
||||||
start = stop
|
params[:range_start] = params[:range_end]
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
@ -81,9 +77,10 @@ returns
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
result = Report::TicketFirstSolution.items(
|
result = Report::TicketFirstSolution.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: selector, # ticket selector to get only a collection of tickets
|
selector: selector, # ticket selector to get only a collection of tickets
|
||||||
|
timezone: 'Europe/Berlin',
|
||||||
)
|
)
|
||||||
|
|
||||||
returns
|
returns
|
||||||
|
|
|
@ -3,11 +3,12 @@ class Report::TicketGenericTime
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
result = Report::TicketGenericTime.aggs(
|
result = Report::TicketGenericTime.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: selector, # ticket selector to get only a collection of tickets
|
selector: selector, # ticket selector to get only a collection of tickets
|
||||||
params: { field: 'created_at', selector: selector_sub },
|
params: { field: 'created_at', selector: selector_sub },
|
||||||
|
timezone: 'Europe/Berlin',
|
||||||
)
|
)
|
||||||
|
|
||||||
returns
|
returns
|
||||||
|
@ -16,17 +17,19 @@ returns
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.aggs(params)
|
def self.aggs(params_origin)
|
||||||
|
params = params_origin.dup
|
||||||
interval_es = params[:interval]
|
interval_es = params[:interval]
|
||||||
if params[:interval] == 'week'
|
if params[:interval] == 'week'
|
||||||
interval_es = 'day'
|
interval_es = 'day'
|
||||||
end
|
end
|
||||||
|
|
||||||
aggs_interval = {
|
aggs_interval = {
|
||||||
from: params[:range_start],
|
from: params[:range_start].iso8601,
|
||||||
to: params[:range_end],
|
to: params[:range_end].iso8601,
|
||||||
interval: interval_es, # year, quarter, month, week, day, hour, minute, second
|
interval: interval_es, # year, quarter, month, week, day, hour, minute, second
|
||||||
field: params[:params][:field],
|
field: params[:params][:field],
|
||||||
|
timezone: params[:timezone],
|
||||||
}
|
}
|
||||||
|
|
||||||
without_merged_tickets = {
|
without_merged_tickets = {
|
||||||
|
@ -42,22 +45,16 @@ returns
|
||||||
end
|
end
|
||||||
selector.merge!(without_merged_tickets) # do not show merged tickets in reports
|
selector.merge!(without_merged_tickets) # do not show merged tickets in reports
|
||||||
|
|
||||||
result_es = SearchIndexBackend.selectors(['Ticket'], selector, nil, nil, aggs_interval)
|
result_es = SearchIndexBackend.selectors(['Ticket'], selector, {}, aggs_interval)
|
||||||
|
|
||||||
if params[:interval] == 'month'
|
if params[:interval] == 'month'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 12
|
stop_interval = 12
|
||||||
elsif params[:interval] == 'week'
|
elsif params[:interval] == 'week'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 7
|
stop_interval = 7
|
||||||
elsif params[:interval] == 'day'
|
elsif params[:interval] == 'day'
|
||||||
start = Date.parse(params[:range_start])
|
stop_interval = ((params[:range_end] - params[:range_start]) / 86_400).to_i + 1
|
||||||
stop_interval = 31
|
|
||||||
elsif params[:interval] == 'hour'
|
elsif params[:interval] == 'hour'
|
||||||
start = Time.zone.parse(params[:range_start])
|
|
||||||
stop_interval = 24
|
stop_interval = 24
|
||||||
elsif params[:interval] == 'minute'
|
elsif params[:interval] == 'minute'
|
||||||
start = Time.zone.parse(params[:range_start])
|
|
||||||
stop_interval = 60
|
stop_interval = 60
|
||||||
end
|
end
|
||||||
result = []
|
result = []
|
||||||
|
@ -77,43 +74,51 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
result_es['aggregations']['time_buckets']['buckets'].each do |item|
|
result_es['aggregations']['time_buckets']['buckets'].each do |item|
|
||||||
if params[:interval] == 'minute'
|
key_as_string = Time.zone.parse(item['key_as_string'])
|
||||||
item['key_as_string'] = item['key_as_string'].sub(/:\d\d.\d\d\dZ$/, '')
|
|
||||||
start_string = start.iso8601.sub(/:\d\dZ$/, '')
|
|
||||||
else
|
|
||||||
start_string = start.iso8601.sub(/:\d\d:\d\d.+?$/, '')
|
|
||||||
end
|
|
||||||
next if !item['doc_count']
|
next if !item['doc_count']
|
||||||
next if item['key_as_string'] !~ /#{start_string}/
|
next if item['doc_count'].zero?
|
||||||
|
|
||||||
|
# only compare date - in certain cases elasticsearch timezone offset will not match
|
||||||
|
replace = ':\d\dZ$'
|
||||||
|
if params[:interval] == 'month'
|
||||||
|
replace = '\d\dT\d\d:\d\d:\d\dZ$'
|
||||||
|
elsif params[:interval] == 'day' || params[:interval] == 'week'
|
||||||
|
replace = '\d\d:\d\d:\d\dZ$'
|
||||||
|
end
|
||||||
|
Rails.logger.error '-----'
|
||||||
|
Rails.logger.error item
|
||||||
|
Rails.logger.error params[:range_start].iso8601.sub(/#{replace}/, '')
|
||||||
|
|
||||||
|
next if key_as_string.iso8601.sub(/#{replace}/, '') != params[:range_start].iso8601.sub(/#{replace}/, '')
|
||||||
next if match
|
next if match
|
||||||
|
|
||||||
match = true
|
match = true
|
||||||
result.push item['doc_count']
|
result.push item['doc_count']
|
||||||
if params[:interval] == 'month'
|
if params[:interval] == 'month'
|
||||||
start = start.next_month
|
params[:range_start] = params[:range_start].next_month
|
||||||
elsif params[:interval] == 'week'
|
elsif params[:interval] == 'week'
|
||||||
start = start.next_day
|
params[:range_start] = params[:range_start].next_day
|
||||||
elsif params[:interval] == 'day'
|
elsif params[:interval] == 'day'
|
||||||
start = start.next_day
|
params[:range_start] = params[:range_start].next_day
|
||||||
elsif params[:interval] == 'hour'
|
elsif params[:interval] == 'hour'
|
||||||
start = start + 1.hour
|
params[:range_start] = params[:range_start] + 1.hour
|
||||||
elsif params[:interval] == 'minute'
|
elsif params[:interval] == 'minute'
|
||||||
start = start + 1.minute
|
params[:range_start] = params[:range_start] + 1.minute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
next if match
|
next if match
|
||||||
|
|
||||||
result.push 0
|
result.push 0
|
||||||
if params[:interval] == 'month'
|
if params[:interval] == 'month'
|
||||||
start = start.next_month
|
params[:range_start] = params[:range_start].next_month
|
||||||
elsif params[:interval] == 'week'
|
elsif params[:interval] == 'week'
|
||||||
start = start.next_day
|
params[:range_start] = params[:range_start].next_day
|
||||||
elsif params[:interval] == 'day'
|
elsif params[:interval] == 'day'
|
||||||
start = start + 1.day
|
params[:range_start] = params[:range_start] + 1.day
|
||||||
elsif params[:interval] == 'hour'
|
elsif params[:interval] == 'hour'
|
||||||
start = start + 1.hour
|
params[:range_start] = params[:range_start] + 1.hour
|
||||||
elsif params[:interval] == 'minute'
|
elsif params[:interval] == 'minute'
|
||||||
start = start + 1.minute
|
params[:range_start] = params[:range_start] + 1.minute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
|
@ -122,8 +127,8 @@ returns
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: selector, # ticket selector to get only a collection of tickets
|
selector: selector, # ticket selector to get only a collection of tickets
|
||||||
params: { field: 'created_at' },
|
params: { field: 'created_at' },
|
||||||
)
|
)
|
||||||
|
@ -141,8 +146,8 @@ returns
|
||||||
def self.items(params)
|
def self.items(params)
|
||||||
|
|
||||||
aggs_interval = {
|
aggs_interval = {
|
||||||
from: params[:range_start],
|
from: params[:range_start].iso8601,
|
||||||
to: params[:range_end],
|
to: params[:range_end].iso8601,
|
||||||
field: params[:params][:field],
|
field: params[:params][:field],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +169,7 @@ returns
|
||||||
end
|
end
|
||||||
selector.merge!(without_merged_tickets) # do not show merged tickets in reports
|
selector.merge!(without_merged_tickets) # do not show merged tickets in reports
|
||||||
|
|
||||||
result = SearchIndexBackend.selectors(['Ticket'], selector, limit, nil, aggs_interval)
|
result = SearchIndexBackend.selectors(['Ticket'], selector, { limit: limit }, aggs_interval)
|
||||||
return result if params[:sheet].present?
|
return result if params[:sheet].present?
|
||||||
|
|
||||||
assets = {}
|
assets = {}
|
||||||
|
|
|
@ -3,11 +3,12 @@ class Report::TicketMoved < Report::Base
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
result = Report::TicketMoved.aggs(
|
result = Report::TicketMoved.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # quarter, month, week, day, hour, minute, second
|
interval: 'month', # quarter, month, week, day, hour, minute, second
|
||||||
selector: selector, # ticket selector to get only a collection of tickets
|
selector: selector, # ticket selector to get only a collection of tickets
|
||||||
params: { type: 'in' }, # in|out
|
params: { type: 'in' }, # in|out
|
||||||
|
timezone: 'Europe/Berlin',
|
||||||
)
|
)
|
||||||
|
|
||||||
returns
|
returns
|
||||||
|
@ -16,7 +17,8 @@ returns
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.aggs(params)
|
def self.aggs(params_origin)
|
||||||
|
params = params_origin.dup
|
||||||
|
|
||||||
selector = params[:selector]['ticket.group_id']
|
selector = params[:selector]['ticket.group_id']
|
||||||
|
|
||||||
|
@ -31,32 +33,27 @@ returns
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
if params[:interval] == 'month'
|
if params[:interval] == 'month'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 12
|
stop_interval = 12
|
||||||
elsif params[:interval] == 'week'
|
elsif params[:interval] == 'week'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 7
|
stop_interval = 7
|
||||||
elsif params[:interval] == 'day'
|
elsif params[:interval] == 'day'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 31
|
stop_interval = 31
|
||||||
elsif params[:interval] == 'hour'
|
elsif params[:interval] == 'hour'
|
||||||
start = Time.zone.parse(params[:range_start])
|
|
||||||
stop_interval = 24
|
stop_interval = 24
|
||||||
elsif params[:interval] == 'minute'
|
elsif params[:interval] == 'minute'
|
||||||
start = Time.zone.parse(params[:range_start])
|
|
||||||
stop_interval = 60
|
stop_interval = 60
|
||||||
end
|
end
|
||||||
(1..stop_interval).each do |_counter|
|
(1..stop_interval).each do |_counter|
|
||||||
if params[:interval] == 'month'
|
if params[:interval] == 'month'
|
||||||
stop = start.next_month
|
params[:range_end] = params[:range_start].next_month
|
||||||
elsif params[:interval] == 'week'
|
elsif params[:interval] == 'week'
|
||||||
stop = start.next_day
|
params[:range_end] = params[:range_start].next_day
|
||||||
elsif params[:interval] == 'day'
|
elsif params[:interval] == 'day'
|
||||||
stop = start.next_day
|
params[:range_end] = params[:range_start].next_day
|
||||||
elsif params[:interval] == 'hour'
|
elsif params[:interval] == 'hour'
|
||||||
stop = start + 1.hour
|
params[:range_end] = params[:range_start] + 1.hour
|
||||||
elsif params[:interval] == 'minute'
|
elsif params[:interval] == 'minute'
|
||||||
stop = start + 1.minute
|
params[:range_end] = params[:range_start] + 1.minute
|
||||||
end
|
end
|
||||||
local_params = group_attributes(selector, params)
|
local_params = group_attributes(selector, params)
|
||||||
local_selector = params[:selector].clone
|
local_selector = params[:selector].clone
|
||||||
|
@ -74,14 +71,14 @@ returns
|
||||||
object: 'Ticket',
|
object: 'Ticket',
|
||||||
type: 'updated',
|
type: 'updated',
|
||||||
attribute: 'group',
|
attribute: 'group',
|
||||||
start: start,
|
start: params[:range_start],
|
||||||
end: stop,
|
end: params[:range_end],
|
||||||
selector: local_selector
|
selector: local_selector
|
||||||
}
|
}
|
||||||
local_params = defaults.merge(local_params)
|
local_params = defaults.merge(local_params)
|
||||||
count = history_count(local_params)
|
count = history_count(local_params)
|
||||||
result.push count
|
result.push count
|
||||||
start = stop
|
params[:range_start] = params[:range_end]
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
@ -89,8 +86,8 @@ returns
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
result = Report::TicketMoved.items(
|
result = Report::TicketMoved.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: selector, # ticket selector to get only a collection of tickets
|
selector: selector, # ticket selector to get only a collection of tickets
|
||||||
params: { type: 'in' }, # in|out
|
params: { type: 'in' }, # in|out
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,10 +3,11 @@ class Report::TicketReopened < Report::Base
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
result = Report::TicketReopened.aggs(
|
result = Report::TicketReopened.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # quarter, month, week, day, hour, minute, second
|
interval: 'month', # quarter, month, week, day, hour, minute, second
|
||||||
selector: selector, # ticket selector to get only a collection of tickets
|
selector: selector, # ticket selector to get only a collection of tickets
|
||||||
|
timezone: 'Europe/Berlin',
|
||||||
)
|
)
|
||||||
|
|
||||||
returns
|
returns
|
||||||
|
@ -15,7 +16,8 @@ returns
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.aggs(params)
|
def self.aggs(params_origin)
|
||||||
|
params = params_origin.dup
|
||||||
ticket_state_ids = ticket_ids
|
ticket_state_ids = ticket_ids
|
||||||
|
|
||||||
interval = params[:interval]
|
interval = params[:interval]
|
||||||
|
@ -25,32 +27,27 @@ returns
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
if params[:interval] == 'month'
|
if params[:interval] == 'month'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 12
|
stop_interval = 12
|
||||||
elsif params[:interval] == 'week'
|
elsif params[:interval] == 'week'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 7
|
stop_interval = 7
|
||||||
elsif params[:interval] == 'day'
|
elsif params[:interval] == 'day'
|
||||||
start = Date.parse(params[:range_start])
|
|
||||||
stop_interval = 31
|
stop_interval = 31
|
||||||
elsif params[:interval] == 'hour'
|
elsif params[:interval] == 'hour'
|
||||||
start = Time.zone.parse(params[:range_start])
|
|
||||||
stop_interval = 24
|
stop_interval = 24
|
||||||
elsif params[:interval] == 'minute'
|
elsif params[:interval] == 'minute'
|
||||||
start = Time.zone.parse(params[:range_start])
|
|
||||||
stop_interval = 60
|
stop_interval = 60
|
||||||
end
|
end
|
||||||
(1..stop_interval).each do |_counter|
|
(1..stop_interval).each do |_counter|
|
||||||
if params[:interval] == 'month'
|
if params[:interval] == 'month'
|
||||||
stop = start.next_month
|
params[:range_end] = params[:range_start].next_month
|
||||||
elsif params[:interval] == 'week'
|
elsif params[:interval] == 'week'
|
||||||
stop = start.next_day
|
params[:range_end] = params[:range_start].next_day
|
||||||
elsif params[:interval] == 'day'
|
elsif params[:interval] == 'day'
|
||||||
stop = start.next_day
|
params[:range_end] = params[:range_start].next_day
|
||||||
elsif params[:interval] == 'hour'
|
elsif params[:interval] == 'hour'
|
||||||
stop = start + 1.hour
|
params[:range_end] = params[:range_start] + 1.hour
|
||||||
elsif params[:interval] == 'minute'
|
elsif params[:interval] == 'minute'
|
||||||
stop = start + 1.minute
|
params[:range_end] = params[:range_start] + 1.minute
|
||||||
end
|
end
|
||||||
|
|
||||||
without_merged_tickets = {
|
without_merged_tickets = {
|
||||||
|
@ -66,12 +63,12 @@ returns
|
||||||
attribute: 'state',
|
attribute: 'state',
|
||||||
id_from: ticket_state_ids,
|
id_from: ticket_state_ids,
|
||||||
id_not_to: ticket_state_ids,
|
id_not_to: ticket_state_ids,
|
||||||
start: start,
|
start: params[:range_start],
|
||||||
end: stop,
|
end: params[:range_end],
|
||||||
selector: params[:selector]
|
selector: params[:selector]
|
||||||
)
|
)
|
||||||
result.push count
|
result.push count
|
||||||
start = stop
|
params[:range_start] = params[:range_end]
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
@ -79,9 +76,10 @@ returns
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
result = Report::TicketReopened.items(
|
result = Report::TicketReopened.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: selector, # ticket selector to get only a collection of tickets
|
selector: selector, # ticket selector to get only a collection of tickets
|
||||||
|
timezone: 'Europe/Berlin',
|
||||||
)
|
)
|
||||||
|
|
||||||
returns
|
returns
|
||||||
|
@ -119,17 +117,17 @@ returns
|
||||||
|
|
||||||
def self.ticket_ids
|
def self.ticket_ids
|
||||||
key = 'Report::TicketReopened::StateList'
|
key = 'Report::TicketReopened::StateList'
|
||||||
ticket_state_ids = Cache.get( key )
|
ticket_state_ids = Cache.get(key)
|
||||||
return ticket_state_ids if ticket_state_ids
|
return ticket_state_ids if ticket_state_ids
|
||||||
|
|
||||||
ticket_state_types = Ticket::StateType.where( name: %w[closed merged removed] )
|
ticket_state_types = Ticket::StateType.where(name: %w[closed merged removed])
|
||||||
ticket_state_ids = []
|
ticket_state_ids = []
|
||||||
ticket_state_types.each do |ticket_state_type|
|
ticket_state_types.each do |ticket_state_type|
|
||||||
ticket_state_type.states.each do |ticket_state|
|
ticket_state_type.states.each do |ticket_state|
|
||||||
ticket_state_ids.push ticket_state.id
|
ticket_state_ids.push ticket_state.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Cache.write( key, ticket_state_ids, { expires_in: 2.days } )
|
Cache.write(key, ticket_state_ids, { expires_in: 2.days })
|
||||||
ticket_state_ids
|
ticket_state_ids
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -442,7 +442,12 @@ get count of tickets and tickets which match on selector
|
||||||
field: 'created_at',
|
field: 'created_at',
|
||||||
}
|
}
|
||||||
|
|
||||||
result = SearchIndexBackend.selectors(index, params[:condition], limit, current_user, aggs_interval)
|
options = {
|
||||||
|
limit: 123,
|
||||||
|
current_user: User.find(123),
|
||||||
|
}
|
||||||
|
|
||||||
|
result = SearchIndexBackend.selectors(index, selector, options, aggs_interval)
|
||||||
|
|
||||||
# for aggregations
|
# for aggregations
|
||||||
result = {
|
result = {
|
||||||
|
@ -470,7 +475,7 @@ get count of tickets and tickets which match on selector
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.selectors(index = nil, selectors = nil, limit = 10, current_user = nil, aggs_interval = nil)
|
def self.selectors(index = nil, selectors = nil, options = {}, aggs_interval = nil)
|
||||||
raise 'no selectors given' if !selectors
|
raise 'no selectors given' if !selectors
|
||||||
|
|
||||||
url = build_url
|
url = build_url
|
||||||
|
@ -486,7 +491,7 @@ get count of tickets and tickets which match on selector
|
||||||
'/_search'
|
'/_search'
|
||||||
end
|
end
|
||||||
|
|
||||||
data = selector2query(selectors, current_user, aggs_interval, limit)
|
data = selector2query(selectors, options, aggs_interval)
|
||||||
|
|
||||||
Rails.logger.info "# curl -X POST \"#{url}\" \\"
|
Rails.logger.info "# curl -X POST \"#{url}\" \\"
|
||||||
Rails.logger.debug { " -d'#{data.to_json}'" }
|
Rails.logger.debug { " -d'#{data.to_json}'" }
|
||||||
|
@ -527,7 +532,13 @@ get count of tickets and tickets which match on selector
|
||||||
response.data
|
response.data
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.selector2query(selector, _current_user, aggs_interval, limit)
|
DEFAULT_SELECTOR_OPTIONS = {
|
||||||
|
limit: 10
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
def self.selector2query(selector, options, aggs_interval)
|
||||||
|
options = DEFAULT_QUERY_OPTIONS.merge(options.deep_symbolize_keys)
|
||||||
|
|
||||||
query_must = []
|
query_must = []
|
||||||
query_must_not = []
|
query_must_not = []
|
||||||
relative_map = {
|
relative_map = {
|
||||||
|
@ -622,9 +633,8 @@ get count of tickets and tickets which match on selector
|
||||||
end
|
end
|
||||||
data = {
|
data = {
|
||||||
query: {},
|
query: {},
|
||||||
size: limit,
|
size: options[:limit],
|
||||||
}
|
}
|
||||||
|
|
||||||
# add aggs to filter
|
# add aggs to filter
|
||||||
if aggs_interval.present?
|
if aggs_interval.present?
|
||||||
if aggs_interval[:interval].present?
|
if aggs_interval[:interval].present?
|
||||||
|
@ -637,6 +647,9 @@ get count of tickets and tickets which match on selector
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if aggs_interval[:timezone].present?
|
||||||
|
data[:aggs][:time_buckets][:date_histogram][:time_zone] = aggs_interval[:timezone]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
r = {}
|
r = {}
|
||||||
r[:range] = {}
|
r[:range] = {}
|
||||||
|
|
|
@ -29,8 +29,8 @@ returns
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
described_class.items(
|
described_class.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
params: { field: 'created_at' },
|
params: { field: 'created_at' },
|
||||||
)
|
)
|
||||||
|
|
|
@ -39,7 +39,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a list of unique tickets (i.e., no duplicates)' do
|
it 'returns a list of unique tickets (i.e., no duplicates)' do
|
||||||
expect(Ticket.selectors(condition, 100, nil, 'full'))
|
expect(Ticket.selectors(condition, limit: 100, access: 'full'))
|
||||||
.to match_array([2, tickets])
|
.to match_array([2, tickets])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,12 +5,6 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
let!(:admin_user) do
|
let!(:admin_user) do
|
||||||
create(:admin_user)
|
create(:admin_user)
|
||||||
end
|
end
|
||||||
let!(:agent_user) do
|
|
||||||
create(:agent_user)
|
|
||||||
end
|
|
||||||
let!(:customer_user) do
|
|
||||||
create(:customer_user)
|
|
||||||
end
|
|
||||||
let!(:year) do
|
let!(:year) do
|
||||||
DateTime.now.utc.year
|
DateTime.now.utc.year
|
||||||
end
|
end
|
||||||
|
@ -23,11 +17,29 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
let!(:day) do
|
let!(:day) do
|
||||||
DateTime.now.utc.day
|
DateTime.now.utc.day
|
||||||
end
|
end
|
||||||
let!(:ticket) do
|
let!(:today) do
|
||||||
create(:ticket, title: 'ticket for report', customer: customer_user)
|
Time.zone.parse('2019-03-15T08:00:00Z')
|
||||||
end
|
end
|
||||||
let!(:article) do
|
let!(:backends) do
|
||||||
create(:ticket_article, ticket_id: ticket.id, type: Ticket::Article::Type.lookup(name: 'note') )
|
{
|
||||||
|
'count::created': true,
|
||||||
|
'count::closed': true,
|
||||||
|
'count::backlog': true,
|
||||||
|
'create_channels::phone_in': true,
|
||||||
|
'create_channels::phone_out': true,
|
||||||
|
'create_channels::email_in': true,
|
||||||
|
'create_channels::email_out': true,
|
||||||
|
'create_channels::web_in': true,
|
||||||
|
'create_channels::twitter_in': true,
|
||||||
|
'create_channels::twitter_out': true,
|
||||||
|
'communication::phone_in': true,
|
||||||
|
'communication::phone_out': true,
|
||||||
|
'communication::email_in': true,
|
||||||
|
'communication::email_out': true,
|
||||||
|
'communication::web_in': true,
|
||||||
|
'communication::twitter_in': true,
|
||||||
|
'communication::twitter_out': true
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
|
@ -35,6 +47,19 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
|
|
||||||
travel 1.minute
|
travel 1.minute
|
||||||
|
|
||||||
|
travel_to today.midday
|
||||||
|
Ticket.destroy_all
|
||||||
|
create(:ticket, title: 'ticket for report #1', created_at: today.midday)
|
||||||
|
create(:ticket, title: 'ticket for report #2', created_at: today.midday + 2.hours)
|
||||||
|
create(:ticket, title: 'ticket for report #3', created_at: today.midday + 2.hours)
|
||||||
|
create(:ticket, title: 'ticket for report #4', created_at: today.midday + 10.hours, state: Ticket::State.lookup(name: 'closed') )
|
||||||
|
create(:ticket, title: 'ticket for report #5', created_at: today.midday + 11.hours)
|
||||||
|
create(:ticket, title: 'ticket for report #6', created_at: today.midday - 11.hours)
|
||||||
|
create(:ticket, title: 'ticket for report #7', created_at: Time.zone.parse('2019-02-28T23:30:00Z'))
|
||||||
|
create(:ticket, title: 'ticket for report #8', created_at: Time.zone.parse('2019-03-01T00:30:00Z'))
|
||||||
|
create(:ticket, title: 'ticket for report #9', created_at: Time.zone.parse('2019-03-31T23:30:00Z'))
|
||||||
|
create(:ticket, title: 'ticket for report #10', created_at: Time.zone.parse('2019-04-01T00:30:00Z'))
|
||||||
|
|
||||||
rebuild_searchindex
|
rebuild_searchindex
|
||||||
|
|
||||||
# execute background jobs
|
# execute background jobs
|
||||||
|
@ -55,5 +80,203 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
expect(@response['Content-Disposition']).to eq('attachment; filename="tickets--all--Created.xls"')
|
expect(@response['Content-Disposition']).to eq('attachment; filename="tickets--all--Created.xls"')
|
||||||
expect(@response['Content-Type']).to eq('application/vnd.ms-excel')
|
expect(@response['Content-Type']).to eq('application/vnd.ms-excel')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does report example - deliver result' do
|
||||||
|
skip('No ES configured') if !SearchIndexBackend.enabled?
|
||||||
|
|
||||||
|
authenticated_as(admin_user)
|
||||||
|
|
||||||
|
# 2019-03-15 - day interval
|
||||||
|
params = {
|
||||||
|
metric: 'count',
|
||||||
|
year: today.year,
|
||||||
|
month: today.month,
|
||||||
|
day: today.day,
|
||||||
|
timeRange: 'day',
|
||||||
|
profiles: {
|
||||||
|
1 => true
|
||||||
|
},
|
||||||
|
backends: backends
|
||||||
|
}
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'Europe/Berlin')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'America/Chicago')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'Australia/Melbourne')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
# 2019-03 - month interval
|
||||||
|
Setting.set('timezone_default', '')
|
||||||
|
params = {
|
||||||
|
metric: 'count',
|
||||||
|
year: today.year,
|
||||||
|
month: today.month,
|
||||||
|
timeRange: 'month',
|
||||||
|
profiles: {
|
||||||
|
1 => true
|
||||||
|
},
|
||||||
|
backends: backends
|
||||||
|
}
|
||||||
|
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'Europe/Berlin')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'America/Chicago')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'Australia/Melbourne')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(json_response['data']['count::created']).to eq([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
# 2019-02 - month interval
|
||||||
|
Setting.set('timezone_default', '')
|
||||||
|
params = {
|
||||||
|
metric: 'count',
|
||||||
|
year: today.year,
|
||||||
|
month: today.month - 1,
|
||||||
|
timeRange: 'month',
|
||||||
|
profiles: {
|
||||||
|
1 => true
|
||||||
|
},
|
||||||
|
backends: backends
|
||||||
|
}
|
||||||
|
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'Europe/Berlin')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'America/Chicago')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'Australia/Melbourne')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
# 2019-04 - month interval
|
||||||
|
Setting.set('timezone_default', '')
|
||||||
|
params = {
|
||||||
|
metric: 'count',
|
||||||
|
year: today.year,
|
||||||
|
month: today.month + 1,
|
||||||
|
timeRange: 'month',
|
||||||
|
profiles: {
|
||||||
|
1 => true
|
||||||
|
},
|
||||||
|
backends: backends
|
||||||
|
}
|
||||||
|
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'Europe/Berlin')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(json_response['data']['count::created']).to eq([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'America/Chicago')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'Australia/Melbourne')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(json_response['data']['count::created']).to eq([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
# 2019 - year interval
|
||||||
|
Setting.set('timezone_default', '')
|
||||||
|
params = {
|
||||||
|
metric: 'count',
|
||||||
|
year: today.year,
|
||||||
|
timeRange: 'year',
|
||||||
|
profiles: {
|
||||||
|
1 => true
|
||||||
|
},
|
||||||
|
backends: backends
|
||||||
|
}
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 1, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 1, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'Europe/Berlin')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 0, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 7, 2, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'America/Chicago')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 2, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 2, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
|
Setting.set('timezone_default', 'Australia/Melbourne')
|
||||||
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response['data']['count::created']).to eq([0, 0, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::closed']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 7, 2, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -730,7 +730,7 @@ class ObjectManagerTest < ActiveSupport::TestCase
|
||||||
value: 'some attribute test3',
|
value: 'some attribute test3',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
assert_equal(tickets[0].id, ticket1.id)
|
assert_equal(tickets[0].id, ticket1.id)
|
||||||
|
|
||||||
|
@ -740,7 +740,7 @@ class ObjectManagerTest < ActiveSupport::TestCase
|
||||||
value: 'some attribute text',
|
value: 'some attribute text',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
assert_equal(tickets[0].id, ticket1.id)
|
assert_equal(tickets[0].id, ticket1.id)
|
||||||
|
|
||||||
|
|
|
@ -291,8 +291,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# first solution
|
# first solution
|
||||||
result = Report::TicketFirstSolution.aggs(
|
result = Report::TicketFirstSolution.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
)
|
)
|
||||||
|
@ -312,8 +312,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketFirstSolution.items(
|
result = Report::TicketFirstSolution.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
)
|
)
|
||||||
assert(result)
|
assert(result)
|
||||||
|
@ -324,8 +324,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# month - with selector #1
|
# month - with selector #1
|
||||||
result = Report::TicketFirstSolution.aggs(
|
result = Report::TicketFirstSolution.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {
|
selector: {
|
||||||
'ticket.priority_id' => {
|
'ticket.priority_id' => {
|
||||||
|
@ -350,8 +350,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketFirstSolution.items(
|
result = Report::TicketFirstSolution.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'ticket.priority_id' => {
|
'ticket.priority_id' => {
|
||||||
'operator' => 'is',
|
'operator' => 'is',
|
||||||
|
@ -365,8 +365,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# month - with merged tickets selector
|
# month - with merged tickets selector
|
||||||
result = Report::TicketFirstSolution.aggs(
|
result = Report::TicketFirstSolution.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {
|
selector: {
|
||||||
'ticket_state.name' => {
|
'ticket_state.name' => {
|
||||||
|
@ -391,8 +391,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketFirstSolution.items(
|
result = Report::TicketFirstSolution.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'ticket_state.name' => {
|
'ticket_state.name' => {
|
||||||
'operator' => 'is not',
|
'operator' => 'is not',
|
||||||
|
@ -406,8 +406,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# month - with selector #2
|
# month - with selector #2
|
||||||
result = Report::TicketFirstSolution.aggs(
|
result = Report::TicketFirstSolution.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {
|
selector: {
|
||||||
'ticket.priority_id' => {
|
'ticket.priority_id' => {
|
||||||
|
@ -432,8 +432,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketFirstSolution.items(
|
result = Report::TicketFirstSolution.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'ticket.priority_id' => {
|
'ticket.priority_id' => {
|
||||||
'operator' => 'is not',
|
'operator' => 'is not',
|
||||||
|
@ -448,8 +448,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# week
|
# week
|
||||||
result = Report::TicketFirstSolution.aggs(
|
result = Report::TicketFirstSolution.aggs(
|
||||||
range_start: '2015-10-26T00:00:00Z',
|
range_start: Time.zone.parse('2015-10-26T00:00:00Z'),
|
||||||
range_end: '2015-10-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-10-31T23:59:59Z'),
|
||||||
interval: 'week', # year, quarter, month, week, day, hour, minute, second
|
interval: 'week', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
)
|
)
|
||||||
|
@ -464,8 +464,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[7])
|
assert_nil(result[7])
|
||||||
|
|
||||||
result = Report::TicketFirstSolution.items(
|
result = Report::TicketFirstSolution.items(
|
||||||
range_start: '2015-10-26T00:00:00Z',
|
range_start: Time.zone.parse('2015-10-26T00:00:00Z'),
|
||||||
range_end: '2015-11-01T23:59:59Z',
|
range_end: Time.zone.parse('2015-11-01T23:59:59Z'),
|
||||||
interval: 'week', # year, quarter, month, week, day, hour, minute, second
|
interval: 'week', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
)
|
)
|
||||||
|
@ -477,8 +477,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# day
|
# day
|
||||||
result = Report::TicketFirstSolution.aggs(
|
result = Report::TicketFirstSolution.aggs(
|
||||||
range_start: '2015-10-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-10-01T00:00:00Z'),
|
||||||
range_end: '2015-11-01T23:59:59Z',
|
range_end: Time.zone.parse('2015-11-01T23:59:59Z'),
|
||||||
interval: 'day', # year, quarter, month, week, day, hour, minute, second
|
interval: 'day', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
)
|
)
|
||||||
|
@ -517,8 +517,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[31])
|
assert_nil(result[31])
|
||||||
|
|
||||||
result = Report::TicketFirstSolution.items(
|
result = Report::TicketFirstSolution.items(
|
||||||
range_start: '2015-10-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-10-01T00:00:00Z'),
|
||||||
range_end: '2015-10-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-10-31T23:59:59Z'),
|
||||||
interval: 'day', # year, quarter, month, week, day, hour, minute, second
|
interval: 'day', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
)
|
)
|
||||||
|
@ -529,8 +529,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# hour
|
# hour
|
||||||
result = Report::TicketFirstSolution.aggs(
|
result = Report::TicketFirstSolution.aggs(
|
||||||
range_start: '2015-10-28T00:00:00Z',
|
range_start: Time.zone.parse('2015-10-28T00:00:00Z'),
|
||||||
range_end: '2015-10-28T23:59:59Z',
|
range_end: Time.zone.parse('2015-10-28T23:59:59Z'),
|
||||||
interval: 'hour', # year, quarter, month, week, day, hour, minute, second
|
interval: 'hour', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
)
|
)
|
||||||
|
@ -562,8 +562,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[24])
|
assert_nil(result[24])
|
||||||
|
|
||||||
result = Report::TicketFirstSolution.items(
|
result = Report::TicketFirstSolution.items(
|
||||||
range_start: '2015-10-28T00:00:00Z',
|
range_start: Time.zone.parse('2015-10-28T00:00:00Z'),
|
||||||
range_end: '2015-10-28T23:59:59Z',
|
range_end: Time.zone.parse('2015-10-28T23:59:59Z'),
|
||||||
interval: 'hour', # year, quarter, month, week, day, hour, minute, second
|
interval: 'hour', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
)
|
)
|
||||||
|
@ -573,8 +573,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# reopen
|
# reopen
|
||||||
result = Report::TicketReopened.aggs(
|
result = Report::TicketReopened.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
)
|
)
|
||||||
|
@ -594,8 +594,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketReopened.items(
|
result = Report::TicketReopened.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
)
|
)
|
||||||
assert(result)
|
assert(result)
|
||||||
|
@ -604,8 +604,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# month - with selector #1
|
# month - with selector #1
|
||||||
result = Report::TicketReopened.aggs(
|
result = Report::TicketReopened.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {
|
selector: {
|
||||||
'ticket.priority_id' => {
|
'ticket.priority_id' => {
|
||||||
|
@ -630,8 +630,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketReopened.items(
|
result = Report::TicketReopened.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'ticket.priority_id' => {
|
'ticket.priority_id' => {
|
||||||
'operator' => 'is',
|
'operator' => 'is',
|
||||||
|
@ -645,8 +645,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# month - with selector #2
|
# month - with selector #2
|
||||||
result = Report::TicketReopened.aggs(
|
result = Report::TicketReopened.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {
|
selector: {
|
||||||
'ticket.priority_id' => {
|
'ticket.priority_id' => {
|
||||||
|
@ -671,8 +671,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketReopened.items(
|
result = Report::TicketReopened.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'ticket.priority_id' => {
|
'ticket.priority_id' => {
|
||||||
'operator' => 'is not',
|
'operator' => 'is not',
|
||||||
|
@ -685,8 +685,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# month - reopened with merge selector
|
# month - reopened with merge selector
|
||||||
result = Report::TicketReopened.aggs(
|
result = Report::TicketReopened.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {
|
selector: {
|
||||||
'ticket_state.name' => {
|
'ticket_state.name' => {
|
||||||
|
@ -711,8 +711,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketReopened.items(
|
result = Report::TicketReopened.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'ticket_state.name' => {
|
'ticket_state.name' => {
|
||||||
'operator' => 'is not',
|
'operator' => 'is not',
|
||||||
|
@ -726,8 +726,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# move in/out without merged status
|
# move in/out without merged status
|
||||||
result = Report::TicketMoved.aggs(
|
result = Report::TicketMoved.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {
|
selector: {
|
||||||
'ticket_state.name' => {
|
'ticket_state.name' => {
|
||||||
|
@ -755,8 +755,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketMoved.items(
|
result = Report::TicketMoved.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'ticket.group_id' => {
|
'ticket.group_id' => {
|
||||||
'operator' => 'is',
|
'operator' => 'is',
|
||||||
|
@ -773,8 +773,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# move in/out
|
# move in/out
|
||||||
result = Report::TicketMoved.aggs(
|
result = Report::TicketMoved.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {
|
selector: {
|
||||||
'ticket.group_id' => {
|
'ticket.group_id' => {
|
||||||
|
@ -802,8 +802,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketMoved.items(
|
result = Report::TicketMoved.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'ticket.group_id' => {
|
'ticket.group_id' => {
|
||||||
'operator' => 'is',
|
'operator' => 'is',
|
||||||
|
@ -820,8 +820,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# out without merged tickets
|
# out without merged tickets
|
||||||
result = Report::TicketMoved.aggs(
|
result = Report::TicketMoved.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {
|
selector: {
|
||||||
'ticket_state.name' => {
|
'ticket_state.name' => {
|
||||||
|
@ -849,8 +849,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketMoved.items(
|
result = Report::TicketMoved.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'ticket_state.name' => {
|
'ticket_state.name' => {
|
||||||
'operator' => 'is not',
|
'operator' => 'is not',
|
||||||
|
@ -866,8 +866,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# out
|
# out
|
||||||
result = Report::TicketMoved.aggs(
|
result = Report::TicketMoved.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {
|
selector: {
|
||||||
'ticket.group_id' => {
|
'ticket.group_id' => {
|
||||||
|
@ -895,8 +895,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketMoved.items(
|
result = Report::TicketMoved.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'ticket.group_id' => {
|
'ticket.group_id' => {
|
||||||
'operator' => 'is',
|
'operator' => 'is',
|
||||||
|
@ -913,8 +913,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# create at
|
# create at
|
||||||
result = Report::TicketGenericTime.aggs(
|
result = Report::TicketGenericTime.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
params: { field: 'created_at' },
|
params: { field: 'created_at' },
|
||||||
|
@ -935,8 +935,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
params: { field: 'created_at' },
|
params: { field: 'created_at' },
|
||||||
)
|
)
|
||||||
|
@ -952,8 +952,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# create at - selector with merge
|
# create at - selector with merge
|
||||||
result = Report::TicketGenericTime.aggs(
|
result = Report::TicketGenericTime.aggs(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||||
selector: {
|
selector: {
|
||||||
'state' => {
|
'state' => {
|
||||||
|
@ -979,8 +979,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[12])
|
assert_nil(result[12])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'state' => {
|
'state' => {
|
||||||
'operator' => 'is not',
|
'operator' => 'is not',
|
||||||
|
@ -1001,8 +1001,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][7])
|
assert_nil(result[:ticket_ids][7])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'created_at' => {
|
'created_at' => {
|
||||||
'operator' => 'before (absolute)',
|
'operator' => 'before (absolute)',
|
||||||
|
@ -1021,8 +1021,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][5])
|
assert_nil(result[:ticket_ids][5])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'created_at' => {
|
'created_at' => {
|
||||||
'operator' => 'after (absolute)',
|
'operator' => 'after (absolute)',
|
||||||
|
@ -1038,8 +1038,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][2])
|
assert_nil(result[:ticket_ids][2])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'created_at' => {
|
'created_at' => {
|
||||||
'operator' => 'before (relative)',
|
'operator' => 'before (relative)',
|
||||||
|
@ -1051,8 +1051,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'created_at' => {
|
'created_at' => {
|
||||||
'operator' => 'after (relative)',
|
'operator' => 'after (relative)',
|
||||||
|
@ -1067,8 +1067,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][0])
|
assert_nil(result[:ticket_ids][0])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2037-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2037-01-01T00:00:00Z'),
|
||||||
range_end: '2037-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2037-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'created_at' => {
|
'created_at' => {
|
||||||
'operator' => 'before (relative)',
|
'operator' => 'before (relative)',
|
||||||
|
@ -1083,8 +1083,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][0])
|
assert_nil(result[:ticket_ids][0])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2037-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2037-01-01T00:00:00Z'),
|
||||||
range_end: '2037-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2037-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'created_at' => {
|
'created_at' => {
|
||||||
'operator' => 'after (relative)',
|
'operator' => 'after (relative)',
|
||||||
|
@ -1100,8 +1100,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][1])
|
assert_nil(result[:ticket_ids][1])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2037-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2037-01-01T00:00:00Z'),
|
||||||
range_end: '2037-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2037-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'created_at' => {
|
'created_at' => {
|
||||||
'operator' => 'before (relative)',
|
'operator' => 'before (relative)',
|
||||||
|
@ -1116,8 +1116,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][0])
|
assert_nil(result[:ticket_ids][0])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2037-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2037-01-01T00:00:00Z'),
|
||||||
range_end: '2037-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2037-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'created_at' => {
|
'created_at' => {
|
||||||
'operator' => 'after (relative)',
|
'operator' => 'after (relative)',
|
||||||
|
@ -1133,8 +1133,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][1])
|
assert_nil(result[:ticket_ids][1])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2037-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2037-01-01T00:00:00Z'),
|
||||||
range_end: '2037-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2037-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'created_at' => {
|
'created_at' => {
|
||||||
'operator' => 'before (relative)',
|
'operator' => 'before (relative)',
|
||||||
|
@ -1149,8 +1149,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][0])
|
assert_nil(result[:ticket_ids][0])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2037-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2037-01-01T00:00:00Z'),
|
||||||
range_end: '2037-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2037-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'created_at' => {
|
'created_at' => {
|
||||||
'operator' => 'after (relative)',
|
'operator' => 'after (relative)',
|
||||||
|
@ -1166,8 +1166,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][1])
|
assert_nil(result[:ticket_ids][1])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'tags' => {
|
'tags' => {
|
||||||
'operator' => 'contains all',
|
'operator' => 'contains all',
|
||||||
|
@ -1182,8 +1182,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][1])
|
assert_nil(result[:ticket_ids][1])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'tags' => {
|
'tags' => {
|
||||||
'operator' => 'contains all not',
|
'operator' => 'contains all not',
|
||||||
|
@ -1203,8 +1203,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][6])
|
assert_nil(result[:ticket_ids][6])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'tags' => {
|
'tags' => {
|
||||||
'operator' => 'contains all',
|
'operator' => 'contains all',
|
||||||
|
@ -1221,8 +1221,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][2])
|
assert_nil(result[:ticket_ids][2])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'tags' => {
|
'tags' => {
|
||||||
'operator' => 'contains all not',
|
'operator' => 'contains all not',
|
||||||
|
@ -1241,8 +1241,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][5])
|
assert_nil(result[:ticket_ids][5])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'tags' => {
|
'tags' => {
|
||||||
'operator' => 'contains one not',
|
'operator' => 'contains one not',
|
||||||
|
@ -1262,8 +1262,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][5])
|
assert_nil(result[:ticket_ids][5])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'tags' => {
|
'tags' => {
|
||||||
'operator' => 'contains one not',
|
'operator' => 'contains one not',
|
||||||
|
@ -1281,8 +1281,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][4])
|
assert_nil(result[:ticket_ids][4])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'tags' => {
|
'tags' => {
|
||||||
'operator' => 'contains one',
|
'operator' => 'contains one',
|
||||||
|
@ -1299,8 +1299,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][2])
|
assert_nil(result[:ticket_ids][2])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'tags' => {
|
'tags' => {
|
||||||
'operator' => 'contains one',
|
'operator' => 'contains one',
|
||||||
|
@ -1317,8 +1317,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][3])
|
assert_nil(result[:ticket_ids][3])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'title' => {
|
'title' => {
|
||||||
'operator' => 'contains',
|
'operator' => 'contains',
|
||||||
|
@ -1339,8 +1339,8 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
assert_nil(result[:ticket_ids][7])
|
assert_nil(result[:ticket_ids][7])
|
||||||
|
|
||||||
result = Report::TicketGenericTime.items(
|
result = Report::TicketGenericTime.items(
|
||||||
range_start: '2015-01-01T00:00:00Z',
|
range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
|
||||||
range_end: '2015-12-31T23:59:59Z',
|
range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
|
||||||
selector: {
|
selector: {
|
||||||
'title' => {
|
'title' => {
|
||||||
'operator' => 'contains not',
|
'operator' => 'contains not',
|
||||||
|
|
|
@ -133,16 +133,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: [99],
|
value: [99],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
# search matching with empty value / missing key
|
# search matching with empty value / missing key
|
||||||
|
@ -156,19 +156,19 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
# search matching with empty value []
|
# search matching with empty value []
|
||||||
|
@ -183,19 +183,19 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
# search matching with empty value ''
|
# search matching with empty value ''
|
||||||
|
@ -209,19 +209,19 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
# search matching
|
# search matching
|
||||||
|
@ -236,19 +236,19 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -261,19 +261,19 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: [Ticket::State.lookup(name: 'open').id],
|
value: [Ticket::State.lookup(name: 'open').id],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -282,19 +282,19 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: nil,
|
value: nil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
# search - created_at
|
# search - created_at
|
||||||
|
@ -308,16 +308,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: '2015-02-05T16:00:00.000Z',
|
value: '2015-02-05T16:00:00.000Z',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 3)
|
assert_equal(ticket_count, 3)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -330,16 +330,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: '2015-02-05T18:00:00.000Z',
|
value: '2015-02-05T18:00:00.000Z',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -352,16 +352,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: '2015-02-05T18:00:00.000Z',
|
value: '2015-02-05T18:00:00.000Z',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 3)
|
assert_equal(ticket_count, 3)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -374,16 +374,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: '2015-02-05T16:00:00.000Z',
|
value: '2015-02-05T16:00:00.000Z',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -397,16 +397,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: '10',
|
value: '10',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 3)
|
assert_equal(ticket_count, 3)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -420,16 +420,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: '10',
|
value: '10',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 3)
|
assert_equal(ticket_count, 3)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -443,16 +443,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: '10',
|
value: '10',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 3)
|
assert_equal(ticket_count, 3)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
# search - updated_at
|
# search - updated_at
|
||||||
|
@ -466,16 +466,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: (Time.zone.now + 1.day).iso8601,
|
value: (Time.zone.now + 1.day).iso8601,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 3)
|
assert_equal(ticket_count, 3)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -488,16 +488,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: (Time.zone.now - 1.day).iso8601,
|
value: (Time.zone.now - 1.day).iso8601,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -510,16 +510,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: (Time.zone.now + 1.day).iso8601,
|
value: (Time.zone.now + 1.day).iso8601,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -532,16 +532,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: (Time.zone.now - 1.day).iso8601,
|
value: (Time.zone.now - 1.day).iso8601,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 3)
|
assert_equal(ticket_count, 3)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -555,16 +555,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: '10',
|
value: '10',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -578,16 +578,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: '10',
|
value: '10',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 3)
|
assert_equal(ticket_count, 3)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -601,21 +601,21 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: '10',
|
value: '10',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 3)
|
assert_equal(ticket_count, 3)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
# invalid conditions
|
# invalid conditions
|
||||||
assert_raise RuntimeError do
|
assert_raise RuntimeError do
|
||||||
ticket_count, tickets = Ticket.selectors(nil, 10)
|
ticket_count, tickets = Ticket.selectors(nil, limit: 10)
|
||||||
end
|
end
|
||||||
|
|
||||||
# search with customers
|
# search with customers
|
||||||
|
@ -629,16 +629,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: 'ticket-selector-customer1',
|
value: 'ticket-selector-customer1',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -651,16 +651,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: 'ticket-selector-customer1-not_existing',
|
value: 'ticket-selector-customer1-not_existing',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 3)
|
assert_equal(ticket_count, 3)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
# search with organizations
|
# search with organizations
|
||||||
|
@ -674,16 +674,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: 'selector',
|
value: 'selector',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
# search with organizations
|
# search with organizations
|
||||||
|
@ -701,16 +701,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: 'ticket-selector-customer1',
|
value: 'ticket-selector-customer1',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -727,16 +727,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: 'ticket-selector-customer1',
|
value: 'ticket-selector-customer1',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
# with owner/customer/org
|
# with owner/customer/org
|
||||||
|
@ -751,16 +751,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: @agent1.id,
|
value: @agent1.id,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -774,16 +774,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
#value: @agent1.id, # value is not set, no result should be shown
|
#value: @agent1.id, # value is not set, no result should be shown
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_nil(ticket_count)
|
assert_nil(ticket_count)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -796,16 +796,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
pre_condition: 'not_set',
|
pre_condition: 'not_set',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -818,16 +818,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
pre_condition: 'not_set',
|
pre_condition: 'not_set',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
UserInfo.current_user_id = @agent1.id
|
UserInfo.current_user_id = @agent1.id
|
||||||
|
@ -841,19 +841,19 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
pre_condition: 'current_user.id',
|
pre_condition: 'current_user.id',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
UserInfo.current_user_id = @agent2.id
|
UserInfo.current_user_id = @agent2.id
|
||||||
|
@ -867,19 +867,19 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
pre_condition: 'current_user.id',
|
pre_condition: 'current_user.id',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
UserInfo.current_user_id = @customer1.id
|
UserInfo.current_user_id = @customer1.id
|
||||||
|
@ -893,19 +893,19 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
pre_condition: 'current_user.id',
|
pre_condition: 'current_user.id',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
UserInfo.current_user_id = @customer2.id
|
UserInfo.current_user_id = @customer2.id
|
||||||
|
@ -919,19 +919,19 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
pre_condition: 'current_user.id',
|
pre_condition: 'current_user.id',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_equal(ticket_count, 2)
|
assert_equal(ticket_count, 2)
|
||||||
|
|
||||||
UserInfo.current_user_id = @customer1.id
|
UserInfo.current_user_id = @customer1.id
|
||||||
|
@ -945,19 +945,19 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
pre_condition: 'current_user.organization_id',
|
pre_condition: 'current_user.organization_id',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
UserInfo.current_user_id = @customer2.id
|
UserInfo.current_user_id = @customer2.id
|
||||||
|
@ -971,19 +971,19 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
pre_condition: 'current_user.organization_id',
|
pre_condition: 'current_user.organization_id',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
|
||||||
assert_equal(ticket_count, 1)
|
assert_equal(ticket_count, 1)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @customer2)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
|
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10)
|
||||||
assert_equal(ticket_count, 0)
|
assert_equal(ticket_count, 0)
|
||||||
travel_back
|
travel_back
|
||||||
end
|
end
|
||||||
|
@ -1055,7 +1055,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: 'contains_all_1, contains_all_2, contains_all_3',
|
value: 'contains_all_1, contains_all_2, contains_all_3',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(1, ticket_count)
|
assert_equal(1, ticket_count)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -1064,7 +1064,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: 'contains_all_1, contains_all_2, contains_all_3, xxx',
|
value: 'contains_all_1, contains_all_2, contains_all_3, xxx',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(0, ticket_count)
|
assert_equal(0, ticket_count)
|
||||||
|
|
||||||
# search all with contains one
|
# search all with contains one
|
||||||
|
@ -1074,7 +1074,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: 'contains_all_1, contains_all_2, contains_all_3',
|
value: 'contains_all_1, contains_all_2, contains_all_3',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(2, ticket_count)
|
assert_equal(2, ticket_count)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -1083,7 +1083,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: 'contains_all_1, contains_all_2'
|
value: 'contains_all_1, contains_all_2'
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(1, ticket_count)
|
assert_equal(1, ticket_count)
|
||||||
|
|
||||||
# search all with contains one not
|
# search all with contains one not
|
||||||
|
@ -1093,7 +1093,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: 'contains_all_1, contains_all_3'
|
value: 'contains_all_1, contains_all_3'
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(2, ticket_count)
|
assert_equal(2, ticket_count)
|
||||||
|
|
||||||
condition = {
|
condition = {
|
||||||
|
@ -1102,7 +1102,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
value: 'contains_all_1, contains_all_2, contains_all_3'
|
value: 'contains_all_1, contains_all_2, contains_all_3'
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, @agent1)
|
ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
|
||||||
assert_equal(2, ticket_count)
|
assert_equal(2, ticket_count)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue