Skip to content
This repository was archived by the owner on Jan 14, 2020. It is now read-only.

Commit 6f1e2e3

Browse files
fix: not working if zone stock counts have no version
Temporary fix for fielded/nav-integrated-national-dashboard#265. It will work only while there is only one version for plans and allocations. Connects fielded/nav-integrated-national-dashboard#265
1 parent 1d7de72 commit 6f1e2e3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/state-indicators.service.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ class StateIndicatorsService {
8585
const location = getLocation(lgas, states, zones, stockCount)
8686
let locationThresholds
8787
if (location && location.level === 'zone') {
88-
locationThresholds = this.thresholdsService.calculateThresholds(location, stockCount, products, requiredAllocations[location._id])
88+
// Temporary fix for https://github.com/fielded/nav-integrated-national-dashboard/issues/265
89+
// This should be removed when https://github.com/fielded/nav-etl/issues/136 is fixed
90+
locationThresholds = this.thresholdsService.calculateThresholds(location, stockCount, products, requiredAllocations[location._id], { version: 'last' })
8991
} else {
9092
locationThresholds = this.thresholdsService.calculateThresholds(location, stockCount, products)
9193
}

test/state-indicators.service.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ describe('state indicators service', function () {
382382
stateIndicatorsService.decorateWithIndicators(stockCounts)
383383
.then(function (decoratedStockCounts) {
384384
expect(thresholdsService.calculateThresholds).toHaveBeenCalledWith(states[0], stockCounts[0], products)
385-
expect(thresholdsService.calculateThresholds).toHaveBeenCalledWith(zones[0], stockCounts[1], products, requiredByState)
385+
expect(thresholdsService.calculateThresholds).toHaveBeenCalledWith(zones[0], stockCounts[1], products, requiredByState, { version: 'last' })
386386
expect(decoratedStockCounts).toEqual(expected)
387387
})
388388
$rootScope.$digest()
@@ -427,7 +427,7 @@ describe('state indicators service', function () {
427427
stateIndicatorsService.decorateWithIndicators(stockCounts)
428428
.then(function (decoratedStockCounts) {
429429
expect(thresholdsService.calculateThresholds).toHaveBeenCalledWith(states[0], stockCounts[0], products)
430-
expect(thresholdsService.calculateThresholds).toHaveBeenCalledWith(zones[0], stockCounts[1], products, undefined)
430+
expect(thresholdsService.calculateThresholds).toHaveBeenCalledWith(zones[0], stockCounts[1], products, undefined, { version: 'last' })
431431
expect(decoratedStockCounts).toEqual(expected)
432432
})
433433
$rootScope.$digest()

0 commit comments

Comments
 (0)