Skip to content

Commit

Permalink
fix(APIv2): adds score to test results
Browse files Browse the repository at this point in the history
  • Loading branch information
petrblaho committed Sep 3, 2024
1 parent 92248e9 commit 392cb3a
Show file tree
Hide file tree
Showing 5 changed files with 4,633 additions and 4,593 deletions.
2 changes: 1 addition & 1 deletion app/serializers/v2/test_result_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module V2
# JSON serialization for Test Results
class TestResultSerializer < V2::ApplicationSerializer
attributes :end_time, :failed_rule_count, :supported
attributes :end_time, :failed_rule_count, :supported, :score

derived_attribute :display_name, system: [:display_name]
derived_attribute :groups, system: [:groups]
Expand Down
4 changes: 4 additions & 0 deletions config/initializers/oj.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
require 'oj'

# https://github.com/ohler55/oj/blob/develop/pages/Options.md#bigdecimal_as_decimal-boolean
Oj.default_options = { bigdecimal_as_decimal: true }

Oj.optimize_rails
6 changes: 6 additions & 0 deletions spec/api/v2/schemas/test_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ module TestResult
readOnly: true,
description: 'Whether the Test Result is compliant or not within a given Report.'
},
score: {
type: :number,
examples: [99.99],
readOnly: true,
description: 'Compliance Score of the System within a given Report.'
},
supported: {
type: %w[boolean null],
examples: [false, true],
Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/v2/test_results_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
os_minor_version: :os_minor_version,
compliant: :compliant,
supported: :supported,
system_id: :system_id
system_id: :system_id,
score: :score
}
end

Expand Down
Loading

0 comments on commit 392cb3a

Please sign in to comment.