Skip to content

Fix query for User count in Header

Closes #924 (closed)

accessible_by(user.ability).workflow_open.ready.or(active).where(assignee: user) führt dazu, dass das OR "active" außerhalb der Bindung von workflow_open steht. Es werden Tasks aus nicht offenen workflows mitgezählt. SELECT COUNT(*) FROM "tasks" INNER JOIN "workflows" ON "workflows"."id" = "tasks"."workflow_id" WHERE ("workflows"."aasm_state" = $1 AND "tasks"."aasm_state" = $2 OR "tasks"."aasm_state" = $3) AND "tasks"."assignee_id" = $4

Mit dieser Reihenfolge: ready.or(active).accessible_by(user.ability).workflow_open.where(assignee: user) baut ActiveRecord die Query wie gewünscht so dass workflow_open sich auf beide task_states auswirkt. SELECT COUNT(*) FROM "tasks" INNER JOIN "workflows" ON "workflows"."id" = "tasks"."workflow_id" WHERE ("tasks"."aasm_state" = $1 OR "tasks"."aasm_state" = $2) AND "workflows"."aasm_state" = $3 AND "tasks"."assignee_id" = $4

Edited by Michael Prilop

Merge request reports