Skip to content

Commit e120426

Browse files
committed
[Fix] make sure maxYear result is always positive
1 parent 0ebaf62 commit e120426

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/modules/dw/CountryProfile/Resources.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export default class Resources {
5252
private defaultArgs;
5353

5454
public static getMaxYear(data: Array<{ year?: number | null }>): number {
55-
const years = data.map(obj => Number(obj.year));
55+
const years = data.map(obj => Number(obj.year)).filter(year => year !== Infinity);
5656

57-
return Math.max.apply(null, years);
57+
return Math.abs(Math.max.apply(null, years));
5858
}
5959
// FIXME: This may not be necessary, category order alone maybe enough
6060
public static getFlowPositions = (flowRefs: IFlowRef[]) => (flow: IFlowRef): number => {
@@ -362,8 +362,6 @@ export default class Resources {
362362
}
363363
private async processResourceData(data: IRAWFlow[]): Promise<DH.IResourceData[]> {
364364
try {
365-
console.log(data);
366-
367365
const processed: IFlowProcessed[] = indicatorDataProcessingSimple<IFlowProcessed>(data);
368366
const flowRefs: IFlowRef[] = await getFlows();
369367
const getPosition = Resources.getFlowPositions(flowRefs);

0 commit comments

Comments
 (0)