Skip to content

Commit

Permalink
Merge pull request #889 from scientist-softserv/i686-omit-data-type-p…
Browse files Browse the repository at this point in the history
…latform-when-data-type-specified

🐛 Omit DataType=Platform when provided DataType does not include Platform
  • Loading branch information
jeremyf authored Oct 30, 2023
2 parents b987092 + e7372eb commit d1805bf
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 d1805bf

Please sign in to comment.