Commit 7698983a authored by Sean McGivern's avatar Sean McGivern

Merge branch 'issue_8475' into 'master'

Fix issues analytics query

Closes #8475

See merge request gitlab-org/gitlab-ee!8509
parents f81d3745 f6981124
......@@ -34,6 +34,7 @@ class IssuablesAnalytics
def issues_created_at_dates
strong_memoize(:issues_created_at_dates) do
issuables
.reorder(nil)
.where('issues.created_at >= ?', months_back.months.ago.beginning_of_month)
.pluck('issues.created_at')
.map { |date| date.strftime(DATE_FORMAT) }
......
---
title: Fix issues analytics query when ordering issues by priority
merge_request: 8509
author:
type: fixed
......@@ -20,6 +20,18 @@ describe IssuablesAnalytics do
end
end
context 'when issuable relation is ordered by priority' do
it 'generates chart data correctly' do
issues = project.issues.order_by_position_and_priority
data = described_class.new(issuables: issues).data
seed.each_pair do |months_back, issues_count|
date = months_back.months.ago.strftime(described_class::DATE_FORMAT)
expect(data[date]).to eq(issues_count)
end
end
end
context 'when months_back parameter is nil' do
it 'returns a hash containing the issues count created in the past 12 months' do
data = described_class.new(issuables: project.issues).data
......
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