Skip to content

Commit

Permalink
composite
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Aug 1, 2024
1 parent b309009 commit 10e231e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 8 deletions.
20 changes: 12 additions & 8 deletions judges/normalize-metrics/normalize-metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
37 changes: 37 additions & 0 deletions judges/normalize-metrics/normalize_composite.yml
Original file line number Diff line number Diff line change
@@ -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]
5 changes: 5 additions & 0 deletions tests/simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -117,13 +120,15 @@
_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
-
_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
Expand Down
2 changes: 2 additions & 0 deletions xsl/qo-section.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ SOFTWARE.
<xsl:text>',borderColor:</xsl:text>
<xsl:choose>
<xsl:when test="$n = 'n_composite'">
<xsl:text>'orange'</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>color.darken(</xsl:text>
<xsl:value-of select="position() * 0.4"/>
<xsl:text>).hex()</xsl:text>
<xsl:text>,borderWidth:1</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>,data:[</xsl:text>
Expand Down

0 comments on commit 10e231e

Please sign in to comment.