Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/ioki/model/operator/reporting/report_aggregation_measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,27 @@ class ReportAggregationMeasure < Base
on: :read,
type: :string

attribute :localized_function,
on: :read,
type: :string

attribute :percentile,
on: :read,
type: :float

attribute :localized_function,
attribute :format_type,
on: :read,
type: :string

attribute :localized_format_type,
on: :read,
type: :string

attribute :measure_type,
attribute :format_unit,
on: :read,
type: :string

attribute :localized_measure_type,
attribute :localized_format_unit,
on: :read,
type: :string
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@

let(:attributes) do
{
type: 'reporting/report_aggregation_measure',
name: 'login_count',
localized_name: 'Logins',
function: 'count_rows',
percentile: nil,
localized_function: 'Count',
measure_type: 'number',
localized_measure_type: 'Count'
type: 'reporting/report_aggregation_measure',
name: 'login_count',
localized_name: 'Logins',
function: 'count_rows',
percentile: nil,
localized_function: 'Count'
}
end

Expand All @@ -22,17 +20,17 @@
it { is_expected.to define_attribute(:function).as(:string) }
it { is_expected.to define_attribute(:percentile).as(:float) }
it { is_expected.to define_attribute(:localized_function).as(:string) }
it { is_expected.to define_attribute(:measure_type).as(:string) }
it { is_expected.to define_attribute(:localized_measure_type).as(:string) }
it { is_expected.to define_attribute(:format_type).as(:string) }
it { is_expected.to define_attribute(:localized_format_type).as(:string) }
it { is_expected.to define_attribute(:format_unit).as(:string) }
it { is_expected.to define_attribute(:localized_format_unit).as(:string) }

it 'casts measure metadata' do
expect(measure.name).to eq('login_count')
expect(measure.localized_name).to eq('Logins')
expect(measure.function).to eq('count_rows')
expect(measure.percentile).to be_nil
expect(measure.localized_function).to eq('Count')
expect(measure.measure_type).to eq('number')
expect(measure.localized_measure_type).to eq('Count')
end

it 'casts percentile values for percentile measures' do
Expand Down
15 changes: 6 additions & 9 deletions spec/ioki/model/operator/reporting/report_aggregation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
},
measures: [
{
type: 'reporting/report_aggregation_measure',
name: 'rides',
localized_name: 'Rides',
function: 'count_rows',
percentile: nil,
localized_function: 'Count',
measure_type: 'number',
localized_measure_type: 'Count'
type: 'reporting/report_aggregation_measure',
name: 'rides',
localized_name: 'Rides',
function: 'count_rows',
percentile: nil,
localized_function: 'Count'
}
],
dimensions: [
Expand Down Expand Up @@ -75,7 +73,6 @@
expect(report_aggregation.measures.first).to be_a(
Ioki::Model::Operator::Reporting::ReportAggregationMeasure
)
expect(report_aggregation.measures.first.measure_type).to eq('number')
expect(report_aggregation.measures.first.percentile).to be_nil
expect(report_aggregation.measures.first.localized_name).to eq('Rides')
expect(report_aggregation.dimensions.first).to be_a(
Expand Down
14 changes: 6 additions & 8 deletions spec/ioki/operator_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1942,14 +1942,12 @@
},
measures: [
{
type: 'reporting/report_aggregation_measure',
name: 'login_count',
localized_name: 'Logins',
function: 'count_rows',
percentile: nil,
localized_function: 'Count',
measure_type: 'number',
localized_measure_type: 'Count'
type: 'reporting/report_aggregation_measure',
name: 'login_count',
localized_name: 'Logins',
function: 'count_rows',
percentile: nil,
localized_function: 'Count'
}
],
dimensions: [],
Expand Down