Maven 1.x Dashboard Plugin

Add "Total" to dashboard report

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Fixed
  • Affects Version/s: 1.7
  • Fix Version/s: 1.8
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    1

Description

Modify jsl to include a "Total" row at bottom of table. See attached image. My code isn't 100%, but as you see it will calculate values correct even if there are some "-" rows. For rows like "xx %", NaN will show up.

Jsl code is quite straight forward (could propably be re-written; my xpath knowledge isn't that good):

<tr>
<td><b>Total</b></td>
<x:forEach var="aggregatorName" select="project[1]/aggregator/@name">
<td>
<b>
<x:expr select="sum(//aggregator[@name='${aggregatorName.value}'][not(text()='-')][text()])"/>
</b>
</td>
</x:forEach>
</tr>

Or do you want a scm diff on this?

Activity

Hide
Vincent Massol added a comment -

Applied thanks.

Show
Vincent Massol added a comment - Applied thanks.
Hide
Morten Kristiansen added a comment -

If you replace this text in the modified dashboard.jsl section i posted, we will get '0' instead of 'NaN' for % columns:

<x:expr select="sum(//aggregator[@name='${aggregatorName.value}'][not(text()='-') and not(contains(text(), '%'))][text()])"/>

Show
Morten Kristiansen added a comment - If you replace this text in the modified dashboard.jsl section i posted, we will get '0' instead of 'NaN' for % columns: <x:expr select="sum(//aggregator[@name='${aggregatorName.value}'][not(text()='-') and not(contains(text(), '%'))][text()])"/>
Hide
Vincent Massol added a comment -

Thanks Morten. Actually, I prerfer NaN over 0 as it's not a number!

That said, the best would really be "N/A" instead of NaN.

Show
Vincent Massol added a comment - Thanks Morten. Actually, I prerfer NaN over 0 as it's not a number! That said, the best would really be "N/A" instead of NaN.
Hide
Morten Kristiansen added a comment -

I see your point. What we could do is to use the "old" <x:expr select..>" but store the select with a <x:set var="theTotal" select=..> and use <j:if..> to set theTotal to "N/A" if theTotal is "NaN".

Show
Morten Kristiansen added a comment - I see your point. What we could do is to use the "old" <x:expr select..>" but store the select with a <x:set var="theTotal" select=..> and use <j:if..> to set theTotal to "N/A" if theTotal is "NaN".
Hide
Morten Kristiansen added a comment -

Here's the new N/A code:

<tr>
<td><b>Total</b></td>
<x:forEach var="aggregatorName" select="project[1]/aggregator/@name">
<td>
<b>
<x:set var="theTotal" select="sum(//aggregator[@name='${aggregatorName.value}'][not(text()='-')][text()])"/>
<j:if test="${theTotal == 'NaN'}">
<j:set var="theTotal" value="N/A" />
</j:if>
<x:expr select="round(${theTotal})" />
</b>
</td>
</x:forEach>
</tr>

Show
Morten Kristiansen added a comment - Here's the new N/A code: <tr> <td><b>Total</b></td> <x:forEach var="aggregatorName" select="project[1]/aggregator/@name"> <td> <b> <x:set var="theTotal" select="sum(//aggregator[@name='${aggregatorName.value}'][not(text()='-')][text()])"/> <j:if test="${theTotal == 'NaN'}"> <j:set var="theTotal" value="N/A" /> </j:if> <x:expr select="round(${theTotal})" /> </b> </td> </x:forEach> </tr>
Hide
Morten Kristiansen added a comment -

Sorry. THIS is more correct:

<tr>
<td><b>Total</b></td>
<x:forEach var="aggregatorName" select="project[1]/aggregator/@name">
<td>
<b>
<x:set var="theTotal" select="sum(//aggregator[@name='${aggregatorName.value}'][not(text()='-')][text()])"/>
<j:choose>
<j:when test="${theTotal == 'NaN'}">
<x:expr select="string('N/A')" />
</j:when>
<j:otherwise>
<x:expr select="round(${theTotal})" />
</j:otherwise>
</j:choose>
</b>
</td>
</x:forEach>
</tr>

Show
Morten Kristiansen added a comment - Sorry. THIS is more correct: <tr> <td><b>Total</b></td> <x:forEach var="aggregatorName" select="project[1]/aggregator/@name"> <td> <b> <x:set var="theTotal" select="sum(//aggregator[@name='${aggregatorName.value}'][not(text()='-')][text()])"/> <j:choose> <j:when test="${theTotal == 'NaN'}"> <x:expr select="string('N/A')" /> </j:when> <j:otherwise> <x:expr select="round(${theTotal})" /> </j:otherwise> </j:choose> </b> </td> </x:forEach> </tr>
Hide
Vincent Massol added a comment -

Applied. Thanks.

Show
Vincent Massol added a comment - Applied. Thanks.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: