Skip to content

Commit

Permalink
#152 payouts to show
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 15, 2024
1 parent 6aca119 commit 973c2e2
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ target/html/%.html: target/output/%
n=$${n%.*}
cp "$$(dirname "$<")/$${n}/$${n}.html" "$$(dirname "$@")/$${n}.html"
cp "$$(dirname "$<")/$${n}/$${n}-vitals.html" "$$(dirname "$@")/$${n}-vitals.html"
xpaths=$$( ruby -e 'require "yaml"; YAML.load_file(ARGV[0], permitted_classes: [Time])[0]["xpaths"].split("\n").each { |x| puts x }' "tests/$${n}.yml" )
while IFS= read -r xpath; do
xmllint --xpath "$${xpath}" "$$(dirname "$@")/$${n}-vitals.html" > /dev/null
done <<< "$${xpaths}"

target/fb/%.fb: tests/%.yml Makefile | target/fb
if [ -e "$@" ]; then $(JUDGES) trim --query='(always)' "$@"; fi
Expand Down
4 changes: 3 additions & 1 deletion tests/empty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
[]
-
xpaths: |
/html
17 changes: 16 additions & 1 deletion tests/simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
-
xpaths: |
/html
/html/head
/html/body
//a[.="@torvalds"]
//span[@class="darkgreen" and .="+14"]
//span[.="129"]
-
_id: 1
what: pmp
Expand Down Expand Up @@ -50,20 +58,23 @@
when: 2024-06-26T22:22:22.8492Z
award: 14
who: 6305016
where: github
is_human: 1
why: for important issue reported
-
_id: 3
when: 2024-06-16T22:22:22.8492Z
award: -56
who: 6305016
where: github
is_human: 1
why: for fun
-
_id: 4
when: 2024-07-05T22:22:22.8492Z
award: -8
who: 526301
where: github
is_human: 1
why: for being a good boy
href: https://github.com/yegor256/judges/issues/111
Expand All @@ -72,6 +83,7 @@
when: 2024-07-04T22:22:22.8492Z
award: 15
who: 526301
where: github
is_human: 1
why: for being a great programmer
href: https://github.com/yegor256/judges/issues/111
Expand All @@ -80,6 +92,7 @@
when: 2024-07-03T22:22:22.8492Z
award: -24
who: 6305016
where: github
is_human: 1
why: for being a bad boy
href: https://github.com/yegor256/judges/issues/111
Expand All @@ -88,6 +101,7 @@
when: 2024-07-02T22:22:22.8492Z
award: 55
who: 6305016
where: github
is_human: 1
why: for new release
href: https://github.com/yegor256/judges/issues/111
Expand Down Expand Up @@ -157,9 +171,10 @@
what: reconciliation
when: 2024-07-01T22:22:22.8492Z
who: 6305016
where: github
since: 2024-06-01T22:22:22.8492Z
awarded: 220
payout: 120
payout: 129
balance: 20
-
_id: 17
Expand Down
3 changes: 3 additions & 0 deletions tests/single-qos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
-
xpaths: |
/html
-
when: 2024-07-03T22:22:22.8492Z
what: quality-of-service
45 changes: 45 additions & 0 deletions xsl/awards.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,51 @@ SOFTWARE.
<xsl:copy-of select="z:payables($name)"/>
</xsl:if>
</tr>
<xsl:if test="$fb/f[what='reconciliation' and who=$id]">
<tr class="sub tablesorter-childRow p_ p_{$name}" style="display: none;">
<td>
<!-- Avatar -->
<xsl:text> </xsl:text>
</td>
<td class="right">
<!-- Reason -->
<xsl:text>Payouts:</xsl:text>
</td>
<xsl:for-each select="1 to $weeks">
<xsl:variable name="week" select="."/>
<td class="right">
<xsl:for-each select="$fb/f[what='reconciliation' and who=$id and z:in-week(when, $week)]">
<xsl:if test="position() &gt; 1">
<br/>
</xsl:if>
<span>
<xsl:attribute name="title">
<xsl:text>Since </xsl:text>
<xsl:value-of select="xs:date(xs:dateTime(since))"/>
<xsl:text> you've accumulated </xsl:text>
<xsl:value-of select="xs:integer(awarded)"/>
<xsl:text> points, a payout of </xsl:text>
<xsl:value-of select="xs:integer(payout)"/>
<xsl:text> points has been made on </xsl:text>
<xsl:value-of select="xs:date(xs:dateTime(when))"/>
<xsl:text>, making the amount payable equal to </xsl:text>
<xsl:value-of select="balance"/>
</xsl:attribute>
<xsl:value-of select="xs:integer(payout)"/>
</span>
</xsl:for-each>
</td>
</xsl:for-each>
<td>
<!-- Run -->
<xsl:text> </xsl:text>
</td>
<td>
<!-- Pay -->
<xsl:text> </xsl:text>
</td>
</tr>
</xsl:if>
<xsl:for-each select="$facts[who_name=$name]">
<xsl:sort select="when" data-type="text"/>
<xsl:variable name="fact" select="."/>
Expand Down

0 comments on commit 973c2e2

Please sign in to comment.