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
begin
if !current_user
ticket_count = Ticket.where(query, *bind_params).joins(tables).count
tickets = Ticket.where(query, *bind_params).joins(tables).limit(limit)
ticket_count = Ticket.where(query, *bind_params).joins(tables).group('tickets.id').count
tickets = Ticket.where(query, *bind_params).joins(tables).group('tickets.id').limit(limit)
return [ticket_count, tickets]
end
access_condition = Ticket.access_condition(current_user, access)
ticket_count = Ticket.where(access_condition).where(query, *bind_params).joins(tables).count
tickets = Ticket.where(access_condition).where(query, *bind_params).joins(tables).limit(limit)
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).group('tickets.id').limit(limit)
return [ticket_count, tickets]
rescue ActiveRecord::StatementInvalid => e

View file

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