Skip to content

Commit

Permalink
šŸ› Omit DataType=Platform when provided DataType does not include Platā€¦
Browse files Browse the repository at this point in the history
ā€¦form

Prior to this commit, if the query parameters included only non-platform
data_type (e.g. article) then we would continue to show the platform
data type node.

With this commit, we skip showing that element if we have been provided
explicit data_type(s) and none of them are Platform.

Related to:

- #686 (comment)
  • Loading branch information
jeremyf committed Oct 30, 2023
1 parent b987092 commit e7372eb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/sushi/platform_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def attribute_performance_for_resource_types

def attribute_performance_for_platform
return [] if metric_type_in_params && metric_types.exclude?("Searches_Platform")
return [] if data_type_in_params && !data_types.find { |dt| dt.casecmp("Platform").zero? }

[{
"Data_Type" => "Platform",
Expand Down
15 changes: 15 additions & 0 deletions spec/models/sushi/platform_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@
expect(subject.dig('Report_Items', 'Attribute_Performance').map { |ap| ap['Data_Type'] }.sort).to match_array(['Article', 'Platform'])
end
end
context 'when given a non-platform data_type and omit searches platform' do
let(:params) do
{
begin_date: '2023-08',
end_date: '2023-09',
data_type: 'article',
attributes_to_show: ['Access_Method', 'Fake_Value'],
granularity: 'totals'
}
end

it 'omits the platform data type' do
expect(subject.dig('Report_Items', 'Attribute_Performance').detect { |dt| dt['Data_Type']['Platform'] }).to be_nil
end
end

context 'with additional params that are not required' do
let(:params) do
Expand Down

0 comments on commit e7372eb

Please sign in to comment.