Commit 5cad6052 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'osw-avoid-wrong-set-of-closed-dates-on-burndown-charts' into 'master'

Avoid wrong closing dates being caught by the query on Burndown charts

Closes gitlab-com/support-forum#3273

See merge request gitlab-org/gitlab-ee!5400
parents 88216ca0 2e504c35
......@@ -88,7 +88,7 @@ class Burndown
# reopened.
internal_clause =
::Issue
.joins("LEFT OUTER JOIN events e ON issues.id = e.target_id AND e.target_type = 'Issue'")
.joins("LEFT OUTER JOIN events e ON issues.id = e.target_id AND e.target_type = 'Issue' AND e.action = #{Event::CLOSED}") # rubocop:disable GitlabSecurity/SqlInjection
.where(milestone: @milestone)
.where("state = 'closed' OR (state = 'opened' AND e.action = #{Event::CLOSED})") # rubocop:disable GitlabSecurity/SqlInjection
......
---
title: Avoid wrong closing dates being caught by the query on Burndown charts
merge_request:
author:
type: fixed
......@@ -110,6 +110,15 @@ describe Burndown do
# Create issues
issues = create_list(:issue, count, issue_params)
issues.each do |issue|
# Turns out we need to make sure older events that are not "closed"
# won't be caught by the query.
Event.create!(author: user,
target: issue,
created_at: Date.yesterday,
action: Event::CREATED)
end
# Close issues
closed = issues.slice(0..count / 2)
closed.each { |issue| close_issue(issue) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment