Commit c0749f85 authored by charlieablett's avatar charlieablett

Add feature flag

Without the feature flag, the DescendantCountService
functionality is used instead
parent cb5eb4d2
...@@ -28,7 +28,7 @@ class GitlabSchema < GraphQL::Schema ...@@ -28,7 +28,7 @@ class GitlabSchema < GraphQL::Schema
default_max_page_size 100 default_max_page_size 100
lazy_resolve Epics::LazyEpicAggregate, :epic_aggregate lazy_resolve ::Epics::LazyEpicAggregate, :epic_aggregate
class << self class << self
def multiplex(queries, **kwargs) def multiplex(queries, **kwargs)
......
...@@ -74,6 +74,8 @@ class Issue < ApplicationRecord ...@@ -74,6 +74,8 @@ class Issue < ApplicationRecord
scope :public_only, -> { where(confidential: false) } scope :public_only, -> { where(confidential: false) }
scope :confidential_only, -> { where(confidential: true) } scope :confidential_only, -> { where(confidential: true) }
scope :counts_by_state, -> { reorder(nil).group(:state_id).count }
ignore_column :state, remove_with: '12.7', remove_after: '2019-12-22' ignore_column :state, remove_with: '12.7', remove_after: '2019-12-22'
after_commit :expire_etag_cache, unless: :importing? after_commit :expire_etag_cache, unless: :importing?
......
...@@ -102,6 +102,8 @@ module EE ...@@ -102,6 +102,8 @@ module EE
scope :start_date_inherited, -> { where(start_date_is_fixed: [nil, false]) } scope :start_date_inherited, -> { where(start_date_is_fixed: [nil, false]) }
scope :due_date_inherited, -> { where(due_date_is_fixed: [nil, false]) } scope :due_date_inherited, -> { where(due_date_is_fixed: [nil, false]) }
scope :counts_by_state, -> { group(:state_id).count }
MAX_HIERARCHY_DEPTH = 5 MAX_HIERARCHY_DEPTH = 5
def etag_caching_enabled? def etag_caching_enabled?
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe 'Epic aggregates (count and weight)' do describe 'Query epic aggregates (count and weight)' do
include GraphqlHelpers include GraphqlHelpers
let_it_be(:current_user) { create(:user) } let_it_be(:current_user) { create(:user) }
...@@ -54,11 +54,6 @@ describe 'Epic aggregates (count and weight)' do ...@@ -54,11 +54,6 @@ describe 'Epic aggregates (count and weight)' do
it_behaves_like 'a working graphql query' it_behaves_like 'a working graphql query'
context 'with feature flag enabled' do
before do
stub_feature_flags(unfiltered_epic_aggregates: true)
end
it 'returns the epic counts' do it 'returns the epic counts' do
epic_count_result = { epic_count_result = {
"openedEpics" => 1, "openedEpics" => 1,
...@@ -91,51 +86,4 @@ describe 'Epic aggregates (count and weight)' do ...@@ -91,51 +86,4 @@ describe 'Epic aggregates (count and weight)' do
a_hash_including('descendantWeightSum' => a_hash_including(descendant_weight_result)) a_hash_including('descendantWeightSum' => a_hash_including(descendant_weight_result))
) )
end end
end
context 'with feature flag disabled' do
before do
stub_feature_flags(unfiltered_epic_aggregates: false)
end
context 'when requesting counts' do
let(:epic_aggregates_query) do
<<~QUERY
nodes {
descendantCounts {
openedEpics
closedEpics
openedIssues
closedIssues
}
}
QUERY
end
it 'uses the DescendantCountService' do
expect(Epics::DescendantCountService).to receive(:new)
post_graphql(query, current_user: current_user)
end
end
context 'when requesting weights' do
let(:epic_aggregates_query) do
<<~QUERY
nodes {
descendantWeightSum {
openedIssues
closedIssues
}
}
QUERY
end
it 'returns an error' do
post_graphql(query, current_user: current_user)
expect_graphql_errors_to_include /Field 'descendantWeightSum' doesn't exist on type 'Epic/
end
end
end
end end
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