Reputation: 856
I want to do some advanced Velocity querying, comparing and calculating and then display the result in the standard live report pages charts etc.
Upvotes: 0
Views: 627
Reputation: 856
In this example, I wanted to separate all defects that have the last digit of version number below a certain version number and the ones above. Like this I could see which defects are fixed in the latest test candidate and below and which are not fixed in it, because are included after the test version was built.
I created a Page Parameter named Build and filled it with 1.3.5.15789
Then I created a Page Script to find the ids of the relevant defects:
#set($projId="my id")
#set($proj = $trackerService.getTrackerProject($projId))
#set($release = $pageParameters.Release.singleValue().id )
#set($q = "type:defect AND release.KEY:$release AND status:resolved AND resolution:done")
#set($Reqs= $proj.queryWorkItems($q, "~severity"))
#set($partsBuild=$pageParameters.Build.value.split("[.]"))
#set($majorBuild = $math.toInteger( $listTool.get($partsBuild,0)))
#set($minorBuild = $math.toInteger( $listTool.get($partsBuild,1)))
#set($patchBuild = $math.toInteger( $listTool.get($partsBuild,2)))
#set($buildBuild = $math.toInteger( $listTool.get($partsBuild,3)))
#set($defectsWaiting =" dummy ")
#set($defectsReady = " dummy ")
#set($numWaiting=0)
#set($numReady=0)
#foreach ($defect in $Reqs)
#set($fixedIn= $defect.getValue("fixedin"))
#set($partsFixedIn = $fixedIn.split("[.]"))
#set($majorFixed = $math.toInteger( $listTool.get($partsFixedIn,0)))
#set($minorFixed = $math.toInteger( $listTool.get($partsFixedIn,1)))
#set($patchFixed = $math.toInteger( $listTool.get($partsFixedIn,2)))
#set($buildFixed = $math.toInteger( $listTool.get($partsFixedIn,3)))
#if( $listTool.size($partsFixedIn)<4 || $listTool.get($partsFixedIn,3) == "X" || $listTool.get($partsFixedIn,3) == "x" || $listTool.get($partsFixedIn,3) == "")
##set($x = $defectsReady.add($defect))
#set($defectsReady="$defectsReady $defect.id")
#set($numReady=$numReady+1)
#else
#if($majorBuild < $majorFixed)
##set($x = $defectsWaiting.add($defect))
#set($defectsWaiting="$defectsWaiting $defect.id")
#set($numWaiting=$numWaiting+1)
#else
#if($minorBuild < $minorFixed)
#set($defectsWaiting="$defectsWaiting $defect.id")
#set($numWaiting=$numWaiting+1)
##set($x = $defectsWaiting.add($defect))
#else
#if($patchBuild < $patchFixed)
##set($x = $defectsWaiting.add($defect))
#set($defectsWaiting="$defectsWaiting $defect.id")
#set($numWaiting=$numWaiting+1)
#else
#if($buildBuild < $buildFixed)
##set($x = $defectsWaiting.add($defect))
#set($defectsWaiting="$defectsWaiting $defect.id")
#set($numWaiting=$numWaiting+1)
#else
##set($x = $defectsReady.add($defect))
#set($defectsReady="$defectsReady $defect.id")
#set($numReady=$numReady+1)
#end
#end
#end
#end
#end
#end
ready: $numReady
waiting: $numWaiting
$!scriptedPageParameters.put("defectsReady", $factory.string("defectsReady").value($defectsReady).build())
$!scriptedPageParameters.put("defectsWaiting", $factory.string("defectsWaiting").value($defectsWaiting).build())
This will add two additional Page Parameters "defectsReady" and "defectsWaiting".
In the widget, I set the query type to "Lucene + Velocity" and the query to id:($pageParameters.defectsWaiting.value)
The initial dummy value will never be found, but will create an intact query, in case there are no ids found.
Upvotes: 0