From 10e231e391be280ac477228b143f133efc664ccb Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 1 Aug 2024 14:57:47 +0300 Subject: [PATCH] composite --- judges/normalize-metrics/normalize-metrics.rb | 20 ++++++---- .../normalize-metrics/normalize_composite.yml | 37 +++++++++++++++++++ tests/simple.yml | 5 +++ xsl/qo-section.xsl | 2 + 4 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 judges/normalize-metrics/normalize_composite.yml diff --git a/judges/normalize-metrics/normalize-metrics.rb b/judges/normalize-metrics/normalize-metrics.rb index 1d65e2c..7c0eb84 100644 --- a/judges/normalize-metrics/normalize-metrics.rb +++ b/judges/normalize-metrics/normalize-metrics.rb @@ -24,6 +24,13 @@ require 'fbe/fb' +def fits(name) + return true if name == 'composite' + return false unless name.match?(/^[a-z]+_[a-z]+.*$/) + return false if name.start_with?('n_') + true +end + %w[quantity-of-deliverables quality-of-service].each do |kind| facts = Fbe.fb.query("(eq what '#{kind}')").each.to_a @@ -33,24 +40,21 @@ start = {} first = facts.first first.all_properties.each do |prop| - next unless prop.match?(/^[a-z]+_[a-z]+.*$/) - next if prop.start_with?('n_') - start[prop] = first[prop][0] + next unless fits(prop) + start[prop] = first[prop][0].to_f end facts.drop(1).each do |f| f.all_properties.each do |prop| - next unless prop.match?(/^[a-z]+_[a-z]+.*$/) - next if prop.start_with?('n_') - v = f[prop][0] + next unless fits(prop) + v = f[prop][0].to_f start[prop] = v if start[prop].nil? end end facts.each do |f| f.all_properties.each do |prop| - next unless prop.match?(/^[a-z]+_[a-z]+.*$/) - next if prop.start_with?('n_') + next unless fits(prop) v = f[prop][0] s = start[prop] diff = v - s diff --git a/judges/normalize-metrics/normalize_composite.yml b/judges/normalize-metrics/normalize_composite.yml new file mode 100644 index 0000000..50a9468 --- /dev/null +++ b/judges/normalize-metrics/normalize_composite.yml @@ -0,0 +1,37 @@ +# MIT License +# +# Copyright (c) 2024 Zerocracy +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +--- +options: + testing: true +input: + - + when: 2024-05-18T22:22:22.8492Z + what: quality-of-service + composite: 100 + - + when: 2024-05-19T22:22:22.8492Z + what: quality-of-service + composite: 120 +expected: + - /fb[count(f)=2] + - /fb/f[composite = 100 and n_composite = 0.0] + - /fb/f[composite = 120 and n_composite = 0.2] diff --git a/tests/simple.yml b/tests/simple.yml index 024d35b..86deb48 100644 --- a/tests/simple.yml +++ b/tests/simple.yml @@ -95,6 +95,7 @@ _id: 8 when: 2024-07-03T22:22:22.8492Z what: quality-of-service + composite: 1224.8 average_issue_lifetime: 433.54 average_pull_lifetime: 3222.98 average_release_interval: 43432.42 @@ -103,12 +104,14 @@ _id: 9 when: 2024-06-23T22:22:22.8492Z what: quality-of-service + composite: 1324.8 average_pull_lifetime: 3989.98 average_release_interval: 41432.42 - _id: 10 when: 2024-06-03T22:22:22.8492Z what: quality-of-service + composite: 1024.8 average_issue_lifetime: 323.54 average_pull_lifetime: 2092.98 average_release_interval: 40432.42 @@ -117,6 +120,7 @@ _id: 11 when: 2024-06-23T22:22:22.8492Z what: quantity-of-deliverables + composite: 18 total_commits_pushed: 43 total_issues_created: 2 total_pulls_submitted: 2 @@ -124,6 +128,7 @@ _id: 12 when: 2024-07-01T22:22:22.8492Z what: quantity-of-deliverables + composite: 20 total_commits_pushed: 41 total_issues_created: 5 total_pulls_submitted: 4 diff --git a/xsl/qo-section.xsl b/xsl/qo-section.xsl index 02532a4..6323c45 100644 --- a/xsl/qo-section.xsl +++ b/xsl/qo-section.xsl @@ -69,11 +69,13 @@ SOFTWARE. ',borderColor: + 'orange' color.darken( ).hex() + ,borderWidth:1 ,data:[