Commit f6981124 authored by Felipe Artur's avatar Felipe Artur

Fix issues analytics query

When issues were being ordered by priority the issues analyitics query
was breaking. This commit ignores the order in the query.
parent 45c53ba5
......@@ -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