Skip to content

Commit

Permalink
Support score names #3369
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Dec 9, 2024
1 parent 8fd6af3 commit 93fa773
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/main/groovy/au/org/ala/merit/Score.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Score {
String label
String units
String category
String name
boolean isOutputTarget

int overDeliveryThreshold = OVER_DELIVERY_PERCENTAGE_THRESHOLD
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package au.org.ala.merit.reports

import au.org.ala.ecodata.forms.ActivityFormService
import au.org.ala.merit.MetadataService
import groovy.util.logging.Slf4j
import org.springframework.beans.factory.annotation.Autowired
/**
Expand All @@ -13,6 +14,8 @@ class ReportLifecycleListener {
boolean deleteSiteOnReset = true
@Autowired
ActivityFormService activityFormService
@Autowired
MetadataService metadataService

Map getContextData(Map context, Map report) { [:] }
Map getOutputData(Map context, Map outputConfig, Map report) { [:] }
Expand Down Expand Up @@ -91,18 +94,24 @@ class ReportLifecycleListener {
result
}

static Map getTargetsForReportPeriod(Map report, List<Map> outputTargets) {
Map getTargetsForReportPeriod(Map report, List<Map> outputTargets) {
String endDate = report.toDate

outputTargets?.collectEntries { Map outputTarget ->
String scoreId = outputTarget.scoreId
String name = scoreName(scoreId) ?: scoreId
String previousPeriod = ''
Map matchingPeriodTarget = outputTarget?.periodTargets?.find { Map periodTarget ->
previousPeriod < endDate && periodTarget.period >= endDate
}
[(scoreId): matchingPeriodTarget?.target]
[(name): matchingPeriodTarget?.target]
}
}

String scoreName(String scoreId) {
List scores = metadataService.getScores(false)
scores.find { it.scoreId == scoreId }?.name
}


}
17 changes: 15 additions & 2 deletions src/main/scripts/releases/4.1/configureIPPRS.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ var scores = [
{
"category": "Indigenous Procurement",
"configuration": {
"filter": {
filterValue: "Regional capacity services - reporting",
property: "name",
type: "filter"
},
"childAggregations": [{
"property": "data.workforcePerformancePercentage",
"type": "AVERAGE"
Expand All @@ -27,11 +32,17 @@ var scores = [
"label": "Indigenous workforce performance",
"outputType": "Regional capacity services - reporting",
"scoreId": indigenousWorkforcePerformanceScoreId,
"status": "active"
"status": "active",
"name":"targetIndigenousParticipationPercentage"
},
{
"category": "Indigenous Procurement",
"configuration": {
"filter": {
filterValue: "Regional capacity services - reporting",
property: "name",
type: "filter"
},
"childAggregations": [{
"property": "data.workforcePerformancePercentage",
"type": "AVERAGE"
Expand All @@ -45,7 +56,8 @@ var scores = [
"label": "Indigenous supply chain performance",
"outputType": "Regional capacity services - reporting",
"scoreId": indigenousSupplyChainPerformanceScoreId,
"status": "active"
"status": "active",
"name":"targetIndigenousProcurementPercentage"
}
];

Expand All @@ -54,6 +66,7 @@ for (var i=0; i<scores.length; i++) {
if (existing.hasNext()) {
var existingScore = existing.next();
existingScore.configuration = scores[i].configuration;
existingScore.name = scores[i].name;
db.score.replaceOne({label:scores[i].label}, existingScore);
}
else {
Expand Down

0 comments on commit 93fa773

Please sign in to comment.