From b34541eeea7a4af238d84734b1116453887de005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serge=20H=C3=A4nni?= Date: Thu, 16 Jul 2026 15:13:27 +0200 Subject: [PATCH] Add `format_type` and `format_unit` to operator API --- .../reporting/report_aggregation_measure.rb | 14 +++++++++--- .../report_aggregation_measure_spec.rb | 22 +++++++++---------- .../reporting/report_aggregation_spec.rb | 15 +++++-------- spec/ioki/operator_api_spec.rb | 14 +++++------- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/lib/ioki/model/operator/reporting/report_aggregation_measure.rb b/lib/ioki/model/operator/reporting/report_aggregation_measure.rb index d766366a..d7fc86f3 100644 --- a/lib/ioki/model/operator/reporting/report_aggregation_measure.rb +++ b/lib/ioki/model/operator/reporting/report_aggregation_measure.rb @@ -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 diff --git a/spec/ioki/model/operator/reporting/report_aggregation_measure_spec.rb b/spec/ioki/model/operator/reporting/report_aggregation_measure_spec.rb index 8f7947c8..23d71098 100644 --- a/spec/ioki/model/operator/reporting/report_aggregation_measure_spec.rb +++ b/spec/ioki/model/operator/reporting/report_aggregation_measure_spec.rb @@ -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 @@ -22,8 +20,10 @@ 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') @@ -31,8 +31,6 @@ 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 diff --git a/spec/ioki/model/operator/reporting/report_aggregation_spec.rb b/spec/ioki/model/operator/reporting/report_aggregation_spec.rb index 4566bdd3..5aeb18e7 100644 --- a/spec/ioki/model/operator/reporting/report_aggregation_spec.rb +++ b/spec/ioki/model/operator/reporting/report_aggregation_spec.rb @@ -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: [ @@ -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( diff --git a/spec/ioki/operator_api_spec.rb b/spec/ioki/operator_api_spec.rb index d4699c27..0a4d8dfd 100644 --- a/spec/ioki/operator_api_spec.rb +++ b/spec/ioki/operator_api_spec.rb @@ -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: [],