Skip to content

Commit

Permalink
qos
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 22, 2024
1 parent 521ebab commit 1a2d747
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target/
target/
.DS_Store
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ $(SAXON): | target

install: $(SAXON) | target
bundle update
npm --no-color install -g uglify-js
npm --no-color install -g [email protected]

$(DIRS):
Expand Down
4 changes: 3 additions & 1 deletion entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ done <<< "${INPUT_OPTIONS}"

# Build a summary HTML.
css=$(cat "${SELF}/target/css/main.css")
js=$(uglifyjs "${SELF}/js/*.js")
html=${INPUT_OUTPUT}/${name}.html
java -jar "${SELF}/target/saxon.jar" \
"-s:${INPUT_OUTPUT}/${name}.rich.xml" \
Expand All @@ -92,5 +93,6 @@ java -jar "${SELF}/target/saxon.jar" \
"fbe=$(bundle info fbe | head -1 | cut -f5 -d' ' | sed s/[\(\)]//g)" \
"name=${name}" \
"logo=${INPUT_LOGO}" \
"css=${css}"
"css=${css}" \
"js=${js}"
echo "HTML generated at ${html}"
34 changes: 34 additions & 0 deletions js/qos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* 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 who_namem 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.
*/

$(function() {
const ctx = document.getElementById('qos');
new Chart(ctx, {
type: 'line',
data: qos_data,
options: {
responsive: false,
}
});
});
43 changes: 43 additions & 0 deletions judges/normalize-qos-metrics/normalize-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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
average_issue_lifetime: 433.54
average_pull_lifetime: 3222.98
average_release_interval: 43432.42
average_workflow_success_rate: 0.56
-
when: 2024-04-18T22:22:22.8492Z
what: quality-of-service
average_issue_lifetime: 323.54
average_pull_lifetime: 2092.98
average_release_interval: 40432.42
average_workflow_success_rate: 0.67
expected:
- /fb[count(f)=2]
- /fb/f[n_average_issue_lifetime]
- /fb/f[n_average_release_interval]
47 changes: 47 additions & 0 deletions judges/normalize-qos-metrics/normalize-qos-metrics.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true

# 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.

require 'fbe/fb'

facts = Fbe.fb.query('(eq what "quality-of-service")').each.to_a

facts.sort! { |a, b| a.when <=> b.when }
return if facts.empty?

start = {}
first = facts.first
first.all_properties.each do |prop|
next unless prop.match?(/^[a-z]+_[a-z]+.*$/)
start[prop] = first[prop][0]
end

facts.each do |f|
f.all_properties.each do |prop|
next unless prop.match?(/^[a-z]+_[a-z]+.*$/)
v = f[prop][0]
diff = v - start[prop]
diff /= start[prop] unless start[prop].zero?
f.send("n_#{prop}=", diff)
end
end
11 changes: 10 additions & 1 deletion xsl/index.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ SOFTWARE.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:z="https://www.zerocracy.com" exclude-result-prefixes="z">
<xsl:import href="awards.xsl"/>
<xsl:import href="policy.xsl"/>
<xsl:import href="qos.xsl"/>
<xsl:output method="xml" doctype-system="about:legacy-compat" encoding="UTF-8" indent="yes"/>
<xsl:param name="css"/>
<xsl:param name="js"/>
<xsl:param name="name"/>
<xsl:param name="logo"/>
<xsl:param name="version"/>
Expand Down Expand Up @@ -79,8 +81,14 @@ SOFTWARE.
<xsl:call-template name="javascript">
<xsl:with-param name="url">https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.3/js/jquery.tablesorter.min.js</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="javascript">
<xsl:with-param name="url">https://cdn.jsdelivr.net/npm/chart.js</xsl:with-param>
</xsl:call-template>
<script type="text/javascript">
<xsl:value-of select="$js" disable-output-escaping="yes"/>
</script>
<style>
<xsl:value-of select="$css"/>
<xsl:value-of select="$css" disable-output-escaping="yes"/>
</style>
</head>
<body>
Expand Down Expand Up @@ -109,6 +117,7 @@ SOFTWARE.
<article>
<xsl:apply-templates select="/" mode="awards"/>
<xsl:apply-templates select="/fb/f[what='hr-policy']"/>
<xsl:apply-templates select="/fb" mode="qos"/>
</article>
<footer>
<p>
Expand Down
2 changes: 1 addition & 1 deletion xsl/policy.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SOFTWARE.
<xsl:template match="/fb/f[what='hr-policy']">
<div class="policy">
<h2>
<xsl:text>The Rules:</xsl:text>
<xsl:text>Rules of the Game</xsl:text>
</h2>
<div class="columns">
<xsl:value-of select="html" disable-output-escaping="yes"/>
Expand Down
71 changes: 71 additions & 0 deletions xsl/qos.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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 who_namem 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.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/fb" mode="qos">
<xsl:variable name="fb" select="."/>
<div class="qos">
<h2>
<xsl:text>Quality of Service</xsl:text>
</h2>
<div style="width: 800px;">
<canvas id="qos" style="width: 100%">
<xsl:text> </xsl:text>
</canvas>
</div>
</div>
<script type="text/javascript">
<xsl:text>const qos_data = { labels: [</xsl:text>
<xsl:for-each select="f[what='quality-of-service']/when">
<xsl:sort select="when" data-type="text" order="ascending"/>
<xsl:if test="position() &gt; 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:text>'</xsl:text>
<xsl:value-of select="when"/>
<xsl:text>'</xsl:text>
</xsl:for-each>
<xsl:text>],</xsl:text>
<xsl:text>datasets: [</xsl:text>
<xsl:for-each select="tokenize('average_issue_lifetime average_pull_lifetime average_release_interval average_workflow_success_rate', ' ')">
<xsl:variable name="metric" select="."/>
<xsl:if test="position() &gt; 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:text>{ label: '</xsl:text>
<xsl:value-of select="."/>
<xsl:text>', data: [</xsl:text>
<xsl:for-each select="$fb/f[what='quality-of-service']">
<xsl:sort select="when" data-type="text" order="ascending"/>
<xsl:if test="position() &gt; 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="*[name()=concat('n_', $metric)]/text()"/>
</xsl:for-each>
<xsl:text>] }</xsl:text>
</xsl:for-each>
<xsl:text>] };</xsl:text>
</script>
</xsl:template>
</xsl:stylesheet>

0 comments on commit 1a2d747

Please sign in to comment.