Moved to database lookups for overview creation.

This commit is contained in:
Martin Edenhofer 2017-03-27 06:07:46 +02:00
parent 4d454289f9
commit 55f17a226b
2 changed files with 12 additions and 8 deletions

View file

@ -16,7 +16,7 @@ class Ticket::State < ApplicationModel
list tickets by customer list tickets by customer
states = Ticket::State.by_category('open') # open|closed|work_on|work_on_all|pending_reminder|pending_action|merged states = Ticket::State.by_category('open') # open|closed|work_on|work_on_all|viewable|pending_reminder|pending_action|merged
returns: returns:
@ -45,6 +45,10 @@ returns:
return Ticket::State.where( return Ticket::State.where(
state_type_id: Ticket::StateType.where(name: ['new', 'open', 'pending reminder']) state_type_id: Ticket::StateType.where(name: ['new', 'open', 'pending reminder'])
) )
elsif category == 'viewable'
return Ticket::State.where(
state_type_id: Ticket::StateType.where(name: ['new', 'open', 'pending reminder', 'pending action', 'closed', 'removed'])
)
elsif category == 'closed' elsif category == 'closed'
return Ticket::State.where( return Ticket::State.where(
state_type_id: Ticket::StateType.where(name: %w(closed)) state_type_id: Ticket::StateType.where(name: %w(closed))

View file

@ -3311,7 +3311,7 @@ Overview.create_if_not_exists(
condition: { condition: {
'ticket.state_id' => { 'ticket.state_id' => {
operator: 'is', operator: 'is',
value: [ 1, 2, 3, 7 ], value: Ticket::State.by_category('open').pluck(:id),
}, },
'ticket.owner_id' => { 'ticket.owner_id' => {
operator: 'is', operator: 'is',
@ -3338,7 +3338,7 @@ Overview.create_if_not_exists(
condition: { condition: {
'ticket.state_id' => { 'ticket.state_id' => {
operator: 'is', operator: 'is',
value: [1, 2, 3], value: Ticket::State.by_category('work_on_all').pluck(:id),
}, },
'ticket.owner_id' => { 'ticket.owner_id' => {
operator: 'is', operator: 'is',
@ -3365,7 +3365,7 @@ Overview.create_if_not_exists(
condition: { condition: {
'ticket.state_id' => { 'ticket.state_id' => {
operator: 'is', operator: 'is',
value: 3, value: Ticket::State.by_category('pending_reminder').pluck(:id),
}, },
'ticket.owner_id' => { 'ticket.owner_id' => {
operator: 'is', operator: 'is',
@ -3397,7 +3397,7 @@ Overview.create_if_not_exists(
condition: { condition: {
'ticket.state_id' => { 'ticket.state_id' => {
operator: 'is', operator: 'is',
value: [1, 2, 3], value: Ticket::State.by_category('work_on_all').pluck(:id),
}, },
}, },
order: { order: {
@ -3420,7 +3420,7 @@ Overview.create_if_not_exists(
condition: { condition: {
'ticket.state_id' => { 'ticket.state_id' => {
operator: 'is', operator: 'is',
value: [3], value: Ticket::State.by_category('pending_reminder').pluck(:id),
}, },
'ticket.pending_time' => { 'ticket.pending_time' => {
operator: 'within next (relative)', operator: 'within next (relative)',
@ -3473,7 +3473,7 @@ Overview.create_if_not_exists(
condition: { condition: {
'ticket.state_id' => { 'ticket.state_id' => {
operator: 'is', operator: 'is',
value: [ 1, 2, 3, 4, 6, 7 ], value: Ticket::State.by_category('viewable').pluck(:id),
}, },
'ticket.customer_id' => { 'ticket.customer_id' => {
operator: 'is', operator: 'is',
@ -3500,7 +3500,7 @@ Overview.create_if_not_exists(
condition: { condition: {
'ticket.state_id' => { 'ticket.state_id' => {
operator: 'is', operator: 'is',
value: [ 1, 2, 3, 4, 6, 7 ], value: Ticket::State.by_category('viewable').pluck(:id),
}, },
'ticket.organization_id' => { 'ticket.organization_id' => {
operator: 'is', operator: 'is',