#1741 do not show merged issues in reports
This commit is contained in:
parent
df33dc1d71
commit
84121e9fda
4 changed files with 307 additions and 6 deletions
|
@ -22,6 +22,12 @@ class Report
|
|||
dataDownload: true,
|
||||
adapter: Report::TicketGenericTime,
|
||||
params: { field: 'created_at' },
|
||||
condition: {
|
||||
'state' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'closed',
|
||||
|
@ -30,6 +36,12 @@ class Report
|
|||
dataDownload: true,
|
||||
adapter: Report::TicketGenericTime,
|
||||
params: { field: 'close_at' },
|
||||
condition: {
|
||||
'state' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'backlog',
|
||||
|
@ -37,6 +49,12 @@ class Report
|
|||
selected: true,
|
||||
dataDownload: false,
|
||||
adapter: Report::TicketBacklog,
|
||||
condition: {
|
||||
'state' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'first_solution',
|
||||
|
@ -44,6 +62,12 @@ class Report
|
|||
selected: false,
|
||||
dataDownload: true,
|
||||
adapter: Report::TicketFirstSolution,
|
||||
condition: {
|
||||
'ticket_state.name' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'reopened',
|
||||
|
@ -51,6 +75,12 @@ class Report
|
|||
selected: false,
|
||||
dataDownload: true,
|
||||
adapter: Report::TicketReopened,
|
||||
condition: {
|
||||
'ticket_state.name' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'movedin',
|
||||
|
@ -59,6 +89,12 @@ class Report
|
|||
dataDownload: true,
|
||||
adapter: Report::TicketMoved,
|
||||
params: { type: 'in' },
|
||||
condition: {
|
||||
'ticket_state.name' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'movedout',
|
||||
|
@ -67,6 +103,12 @@ class Report
|
|||
dataDownload: true,
|
||||
adapter: Report::TicketMoved,
|
||||
params: { type: 'out' },
|
||||
condition: {
|
||||
'ticket_state.name' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged'
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
config[:metric][:count][:backend] = backend
|
||||
|
|
|
@ -528,6 +528,9 @@ condition example
|
|||
elsif selector[0] == 'article'
|
||||
tables += ', ticket_articles articles'
|
||||
query += 'tickets.id = articles.ticket_id'
|
||||
elsif selector[0] == 'ticket_state'
|
||||
tables += ', ticket_states'
|
||||
query += 'tickets.state_id = ticket_states.id'
|
||||
else
|
||||
raise "invalid selector #{attribute.inspect}->#{selector.inspect}"
|
||||
end
|
||||
|
|
|
@ -459,7 +459,7 @@ get count of tickets and tickets which match on selector
|
|||
elsif data['operator'] == 'contains not'
|
||||
query_must_not.push t
|
||||
else
|
||||
raise "unknown operator '#{data['operator']}'"
|
||||
raise "unknown operator '#{data['operator']}' for #{key}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -245,6 +245,34 @@ class ReportTest < ActiveSupport::TestCase
|
|||
created_by_id: 1,
|
||||
)
|
||||
|
||||
@ticket8 = Ticket.create!(
|
||||
title: 'test 8',
|
||||
group: group1,
|
||||
customer_id: 2,
|
||||
state: Ticket::State.lookup(name: 'merged'),
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
close_at: '2015-11-02 12:30:00 UTC',
|
||||
created_at: '2015-11-02 12:30:00 UTC',
|
||||
updated_at: '2015-11-02 12:30:00 UTC',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
Ticket::Article.create!(
|
||||
ticket_id: @ticket8.id,
|
||||
from: 'some_sender@example.com',
|
||||
to: 'some_recipient@example.com',
|
||||
subject: 'some subject',
|
||||
message_id: 'some@id',
|
||||
body: 'some message article_outbound',
|
||||
internal: false,
|
||||
sender: Ticket::Article::Sender.where(name: 'Agent').first,
|
||||
type: Ticket::Article::Type.where(name: 'email').first,
|
||||
created_at: '2015-11-02 12:30:00 UTC',
|
||||
updated_at: '2015-11-02 12:30:00 UTC',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
|
||||
# execute background jobs
|
||||
Scheduler.worker(true)
|
||||
|
||||
|
@ -276,7 +304,7 @@ class ReportTest < ActiveSupport::TestCase
|
|||
assert_equal(0, result[7])
|
||||
assert_equal(0, result[8])
|
||||
assert_equal(2, result[9])
|
||||
assert_equal(1, result[10])
|
||||
assert_equal(2, result[10])
|
||||
assert_equal(0, result[11])
|
||||
assert_nil(result[12])
|
||||
|
||||
|
@ -289,7 +317,8 @@ class ReportTest < ActiveSupport::TestCase
|
|||
assert_equal(@ticket5.id, result[:ticket_ids][0])
|
||||
assert_equal(@ticket6.id, result[:ticket_ids][1])
|
||||
assert_equal(@ticket7.id, result[:ticket_ids][2])
|
||||
assert_nil(result[:ticket_ids][3])
|
||||
assert_equal(@ticket8.id, result[:ticket_ids][3])
|
||||
assert_nil(result[:ticket_ids][4])
|
||||
|
||||
# month - with selector #1
|
||||
result = Report::TicketFirstSolution.aggs(
|
||||
|
@ -332,6 +361,47 @@ class ReportTest < ActiveSupport::TestCase
|
|||
assert_equal(@ticket5.id, result[:ticket_ids][0])
|
||||
assert_nil(result[:ticket_ids][1])
|
||||
|
||||
# month - with merged tickets selector
|
||||
result = Report::TicketFirstSolution.aggs(
|
||||
range_start: '2015-01-01T00:00:00Z',
|
||||
range_end: '2015-12-31T23:59:59Z',
|
||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||
selector: {
|
||||
'ticket_state.name' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged',
|
||||
}
|
||||
}, # ticket selector to get only a collection of tickets
|
||||
)
|
||||
assert(result)
|
||||
assert_equal(0, result[0])
|
||||
assert_equal(0, result[1])
|
||||
assert_equal(0, result[2])
|
||||
assert_equal(0, result[3])
|
||||
assert_equal(0, result[4])
|
||||
assert_equal(0, result[5])
|
||||
assert_equal(0, result[6])
|
||||
assert_equal(0, result[7])
|
||||
assert_equal(0, result[8])
|
||||
assert_equal(2, result[9])
|
||||
assert_equal(1, result[10])
|
||||
assert_equal(0, result[11])
|
||||
assert_nil(result[12])
|
||||
|
||||
result = Report::TicketFirstSolution.items(
|
||||
range_start: '2015-01-01T00:00:00Z',
|
||||
range_end: '2015-12-31T23:59:59Z',
|
||||
selector: {
|
||||
'ticket_state.name' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged',
|
||||
}
|
||||
}, # ticket selector to get only a collection of tickets
|
||||
)
|
||||
assert(result)
|
||||
assert_equal(@ticket5.id, result[:ticket_ids][0])
|
||||
assert_nil(result[:ticket_ids][3])
|
||||
|
||||
# month - with selector #2
|
||||
result = Report::TicketFirstSolution.aggs(
|
||||
range_start: '2015-01-01T00:00:00Z',
|
||||
|
@ -355,7 +425,7 @@ class ReportTest < ActiveSupport::TestCase
|
|||
assert_equal(0, result[7])
|
||||
assert_equal(0, result[8])
|
||||
assert_equal(1, result[9])
|
||||
assert_equal(1, result[10])
|
||||
assert_equal(2, result[10])
|
||||
assert_equal(0, result[11])
|
||||
assert_nil(result[12])
|
||||
|
||||
|
@ -372,7 +442,8 @@ class ReportTest < ActiveSupport::TestCase
|
|||
assert(result)
|
||||
assert_equal(@ticket6.id, result[:ticket_ids][0])
|
||||
assert_equal(@ticket7.id, result[:ticket_ids][1])
|
||||
assert_nil(result[:ticket_ids][2])
|
||||
assert_equal(@ticket8.id, result[:ticket_ids][2])
|
||||
assert_nil(result[:ticket_ids][3])
|
||||
|
||||
# week
|
||||
result = Report::TicketFirstSolution.aggs(
|
||||
|
@ -611,6 +682,94 @@ class ReportTest < ActiveSupport::TestCase
|
|||
assert(result)
|
||||
assert_nil(result[:ticket_ids][0])
|
||||
|
||||
# month - reopened with merge selector
|
||||
result = Report::TicketReopened.aggs(
|
||||
range_start: '2015-01-01T00:00:00Z',
|
||||
range_end: '2015-12-31T23:59:59Z',
|
||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||
selector: {
|
||||
'ticket_state.name' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged',
|
||||
}
|
||||
}, # ticket selector to get only a collection of tickets
|
||||
)
|
||||
assert(result)
|
||||
assert_equal(0, result[0])
|
||||
assert_equal(0, result[1])
|
||||
assert_equal(0, result[2])
|
||||
assert_equal(0, result[3])
|
||||
assert_equal(0, result[4])
|
||||
assert_equal(0, result[5])
|
||||
assert_equal(0, result[6])
|
||||
assert_equal(0, result[7])
|
||||
assert_equal(0, result[8])
|
||||
assert_equal(1, result[9])
|
||||
assert_equal(0, result[10])
|
||||
assert_equal(0, result[11])
|
||||
assert_nil(result[12])
|
||||
|
||||
result = Report::TicketReopened.items(
|
||||
range_start: '2015-01-01T00:00:00Z',
|
||||
range_end: '2015-12-31T23:59:59Z',
|
||||
selector: {
|
||||
'ticket_state.name' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged',
|
||||
}
|
||||
}, # ticket selector to get only a collection of tickets
|
||||
)
|
||||
assert(result)
|
||||
assert_equal(@ticket5.id, result[:ticket_ids][0])
|
||||
assert_nil(result[:ticket_ids][1])
|
||||
|
||||
# move in/out without merged status
|
||||
result = Report::TicketMoved.aggs(
|
||||
range_start: '2015-01-01T00:00:00Z',
|
||||
range_end: '2015-12-31T23:59:59Z',
|
||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||
selector: {
|
||||
'ticket_state.name' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged',
|
||||
}
|
||||
}, # ticket selector to get only a collection of tickets
|
||||
params: {
|
||||
type: 'in',
|
||||
},
|
||||
)
|
||||
assert(result)
|
||||
assert_equal(0, result[0])
|
||||
assert_equal(0, result[1])
|
||||
assert_equal(0, result[2])
|
||||
assert_equal(0, result[3])
|
||||
assert_equal(0, result[4])
|
||||
assert_equal(0, result[5])
|
||||
assert_equal(0, result[6])
|
||||
assert_equal(0, result[7])
|
||||
assert_equal(0, result[8])
|
||||
assert_equal(0, result[9])
|
||||
assert_equal(0, result[10])
|
||||
assert_equal(0, result[11])
|
||||
assert_nil(result[12])
|
||||
|
||||
result = Report::TicketMoved.items(
|
||||
range_start: '2015-01-01T00:00:00Z',
|
||||
range_end: '2015-12-31T23:59:59Z',
|
||||
selector: {
|
||||
'ticket.group_id' => {
|
||||
'operator' => 'is',
|
||||
'value' => [Group.lookup(name: 'Users').id],
|
||||
}
|
||||
}, # ticket selector to get only a collection of tickets
|
||||
params: {
|
||||
type: 'in',
|
||||
},
|
||||
)
|
||||
assert(result)
|
||||
assert_equal(@ticket1.id, result[:ticket_ids][0])
|
||||
assert_nil(result[:ticket_ids][1])
|
||||
|
||||
# move in/out
|
||||
result = Report::TicketMoved.aggs(
|
||||
range_start: '2015-01-01T00:00:00Z',
|
||||
|
@ -658,6 +817,52 @@ class ReportTest < ActiveSupport::TestCase
|
|||
assert_equal(@ticket1.id, result[:ticket_ids][0])
|
||||
assert_nil(result[:ticket_ids][1])
|
||||
|
||||
# out without merged tickets
|
||||
result = Report::TicketMoved.aggs(
|
||||
range_start: '2015-01-01T00:00:00Z',
|
||||
range_end: '2015-12-31T23:59:59Z',
|
||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||
selector: {
|
||||
'ticket_state.name' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged',
|
||||
}
|
||||
}, # ticket selector to get only a collection of tickets
|
||||
params: {
|
||||
type: 'out',
|
||||
},
|
||||
)
|
||||
assert(result)
|
||||
assert_equal(0, result[0])
|
||||
assert_equal(0, result[1])
|
||||
assert_equal(0, result[2])
|
||||
assert_equal(0, result[3])
|
||||
assert_equal(0, result[4])
|
||||
assert_equal(0, result[5])
|
||||
assert_equal(0, result[6])
|
||||
assert_equal(0, result[7])
|
||||
assert_equal(0, result[8])
|
||||
assert_equal(0, result[9])
|
||||
assert_equal(0, result[10])
|
||||
assert_equal(0, result[11])
|
||||
assert_nil(result[12])
|
||||
|
||||
result = Report::TicketMoved.items(
|
||||
range_start: '2015-01-01T00:00:00Z',
|
||||
range_end: '2015-12-31T23:59:59Z',
|
||||
selector: {
|
||||
'ticket_state.name' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged',
|
||||
}
|
||||
}, # ticket selector to get only a collection of tickets
|
||||
params: {
|
||||
type: 'out',
|
||||
},
|
||||
)
|
||||
assert(result)
|
||||
assert_nil(result[:ticket_ids][0])
|
||||
|
||||
# out
|
||||
result = Report::TicketMoved.aggs(
|
||||
range_start: '2015-01-01T00:00:00Z',
|
||||
|
@ -724,7 +929,7 @@ class ReportTest < ActiveSupport::TestCase
|
|||
assert_equal(0, result[7])
|
||||
assert_equal(0, result[8])
|
||||
assert_equal(6, result[9])
|
||||
assert_equal(1, result[10])
|
||||
assert_equal(2, result[10])
|
||||
assert_equal(0, result[11])
|
||||
assert_nil(result[12])
|
||||
|
||||
|
@ -734,6 +939,57 @@ class ReportTest < ActiveSupport::TestCase
|
|||
selector: {}, # ticket selector to get only a collection of tickets
|
||||
params: { field: 'created_at' },
|
||||
)
|
||||
assert(result)
|
||||
assert_equal(@ticket8.id, result[:ticket_ids][0].to_i)
|
||||
assert_equal(@ticket7.id, result[:ticket_ids][1].to_i)
|
||||
assert_equal(@ticket6.id, result[:ticket_ids][2].to_i)
|
||||
assert_equal(@ticket5.id, result[:ticket_ids][3].to_i)
|
||||
assert_equal(@ticket4.id, result[:ticket_ids][4].to_i)
|
||||
assert_equal(@ticket3.id, result[:ticket_ids][5].to_i)
|
||||
assert_equal(@ticket2.id, result[:ticket_ids][6].to_i)
|
||||
assert_equal(@ticket1.id, result[:ticket_ids][7].to_i)
|
||||
assert_nil(result[:ticket_ids][8])
|
||||
|
||||
# create at - selector with merge
|
||||
result = Report::TicketGenericTime.aggs(
|
||||
range_start: '2015-01-01T00:00:00Z',
|
||||
range_end: '2015-12-31T23:59:59Z',
|
||||
interval: 'month', # year, quarter, month, week, day, hour, minute, second
|
||||
selector: {
|
||||
'state' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged'
|
||||
}
|
||||
}, # ticket selector to get only a collection of tickets
|
||||
params: { field: 'created_at' },
|
||||
)
|
||||
assert(result)
|
||||
assert_equal(0, result[0])
|
||||
assert_equal(0, result[1])
|
||||
assert_equal(0, result[2])
|
||||
assert_equal(0, result[3])
|
||||
assert_equal(0, result[4])
|
||||
assert_equal(0, result[5])
|
||||
assert_equal(0, result[6])
|
||||
assert_equal(0, result[7])
|
||||
assert_equal(0, result[8])
|
||||
assert_equal(6, result[9])
|
||||
assert_equal(1, result[10])
|
||||
assert_equal(0, result[11])
|
||||
assert_nil(result[12])
|
||||
|
||||
result = Report::TicketGenericTime.items(
|
||||
range_start: '2015-01-01T00:00:00Z',
|
||||
range_end: '2015-12-31T23:59:59Z',
|
||||
selector: {
|
||||
'state' => {
|
||||
'operator' => 'is not',
|
||||
'value' => 'merged'
|
||||
}
|
||||
}, # ticket selector to get only a collection of tickets
|
||||
params: { field: 'created_at' },
|
||||
)
|
||||
|
||||
assert(result)
|
||||
assert_equal(@ticket7.id, result[:ticket_ids][0].to_i)
|
||||
assert_equal(@ticket6.id, result[:ticket_ids][1].to_i)
|
||||
|
|
Loading…
Reference in a new issue