Fixed issue #1769 - Ticket shown multiple times in overview.

This commit is contained in:
Rolf Schmidt 2018-02-07 11:44:38 +01:00
parent d33c80bbaa
commit 371a0494b7
2 changed files with 7 additions and 6 deletions

View file

@ -424,14 +424,14 @@ get count of tickets and tickets which match on selector
ActiveRecord::Base.transaction(requires_new: true) do ActiveRecord::Base.transaction(requires_new: true) do
begin begin
if !current_user if !current_user
ticket_count = Ticket.where(query, *bind_params).joins(tables).count ticket_count = Ticket.where(query, *bind_params).joins(tables).group('tickets.id').count
tickets = Ticket.where(query, *bind_params).joins(tables).limit(limit) tickets = Ticket.where(query, *bind_params).joins(tables).group('tickets.id').limit(limit)
return [ticket_count, tickets] return [ticket_count, tickets]
end end
access_condition = Ticket.access_condition(current_user, access) access_condition = Ticket.access_condition(current_user, access)
ticket_count = Ticket.where(access_condition).where(query, *bind_params).joins(tables).count ticket_count = Ticket.where(access_condition).where(query, *bind_params).joins(tables).group('tickets.id').count
tickets = Ticket.where(access_condition).where(query, *bind_params).joins(tables).limit(limit) tickets = Ticket.where(access_condition).where(query, *bind_params).joins(tables).group('tickets.id').limit(limit)
return [ticket_count, tickets] return [ticket_count, tickets]
rescue ActiveRecord::StatementInvalid => e rescue ActiveRecord::StatementInvalid => e

View file

@ -113,10 +113,11 @@ returns
end end
end end
ticket_result = Ticket.select('id, updated_at') ticket_result = Ticket.select('tickets.id, tickets.updated_at')
.where(access_condition) .where(access_condition)
.where(query_condition, *bind_condition) .where(query_condition, *bind_condition)
.joins(tables) .joins(tables)
.group('tickets.id')
.order(order_by) .order(order_by)
.limit(1000) .limit(1000)
.pluck(:id, :updated_at) .pluck(:id, :updated_at)
@ -129,7 +130,7 @@ returns
} }
tickets.push ticket_item tickets.push ticket_item
end end
count = Ticket.where(access_condition).where(query_condition, *bind_condition).joins(tables).count() count = Ticket.where(access_condition).where(query_condition, *bind_condition).joins(tables).group('tickets.id').count()
item = { item = {
overview: { overview: {
name: overview.name, name: overview.name,