Commit 5e32ee44 authored by charlie ablett's avatar charlie ablett

Apply reviewer feedback

- Remove unneeded method
- Rename variable
parent 6c2b0676
...@@ -13,11 +13,11 @@ module Boards ...@@ -13,11 +13,11 @@ module Boards
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def metadata def metadata
issues = item_model.arel_table issuables = item_model.arel_table
keys = metadata_fields.keys keys = metadata_fields.keys
# TODO: eliminate need for SQL literal fragment # TODO: eliminate need for SQL literal fragment
columns = Arel.sql(metadata_fields.values_at(*keys).join(', ')) columns = Arel.sql(metadata_fields.values_at(*keys).join(', '))
results = item_model.where(id: items.select(issues[:id])).pluck(columns) results = item_model.where(id: items.select(issuables[:id])).pluck(columns)
Hash[keys.zip(results.flatten)] Hash[keys.zip(results.flatten)]
end end
......
...@@ -9,18 +9,6 @@ module Boards ...@@ -9,18 +9,6 @@ module Boards
IssuesFinder.valid_params IssuesFinder.valid_params
end end
# rubocop: disable CodeReuse/ActiveRecord
def metadata
issues = Issue.arel_table
keys = metadata_fields.keys
# TODO: eliminate need for SQL literal fragment
columns = Arel.sql(metadata_fields.values_at(*keys).join(', '))
results = Issue.where(id: items.select(issues[:id])).pluck(columns)
Hash[keys.zip(results.flatten)]
end
# rubocop: enable CodeReuse/ActiveRecord
private private
def ordered_items def ordered_items
......
...@@ -12,8 +12,6 @@ RSpec.describe 'get list of epic boards' do ...@@ -12,8 +12,6 @@ RSpec.describe 'get list of epic boards' do
let_it_be(:list2) { create(:epic_list, epic_board: board, list_type: :closed) } let_it_be(:list2) { create(:epic_list, epic_board: board, list_type: :closed) }
let_it_be(:list3) { create(:epic_list, epic_board: board, list_type: :backlog) } let_it_be(:list3) { create(:epic_list, epic_board: board, list_type: :backlog) }
let_it_be(:some_epics) { create_list(:epic, 2, group: group) }
def pagination_query(params = {}) def pagination_query(params = {})
graphql_query_for(:group, { full_path: group.full_path }, graphql_query_for(:group, { full_path: group.full_path },
<<~BOARDS <<~BOARDS
...@@ -82,12 +80,13 @@ RSpec.describe 'get list of epic boards' do ...@@ -82,12 +80,13 @@ RSpec.describe 'get list of epic boards' do
end end
it 'returns the correct values for count' do it 'returns the correct values for count' do
create_list(:epic, 2, group: group) # epics in backlog, the list which is returned first
post_graphql(pagination_query, current_user: current_user) post_graphql(pagination_query, current_user: current_user)
assert_field_value('epicsCount', [2, 0, 0]) assert_field_value('epicsCount', [2, 0, 0])
end end
end end
end
end end
def assert_field_value(field, expected_value) def assert_field_value(field, expected_value)
......
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