AW-3441 another fix...
All checks were successful
FarmMaps/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Store} from '@ngrx/store';
|
||||
import * as appCommonReducer from '../reducers/app-common.reducer';
|
||||
import {IPackage} from '../models/package';
|
||||
import {IPackage, IPackages} from '../models/package';
|
||||
|
||||
import {IItem} from '../models/item';
|
||||
import {IItemTask} from '../models/itemTask';
|
||||
@@ -35,6 +35,22 @@ export class PackageService {
|
||||
}
|
||||
}
|
||||
|
||||
export function getValidPackages(packageMap: IPackages): {[key: string]: IPackage} {
|
||||
const keys = Object.keys(packageMap);
|
||||
return keys.filter(k => {
|
||||
const packages = packageMap[k]
|
||||
.filter((p) => isValidPackage(p));
|
||||
|
||||
return packages.length > 0;
|
||||
}).reduce((map, key) => {
|
||||
const packages = packageMap[key];
|
||||
return {
|
||||
...map,
|
||||
key: packages[0]
|
||||
};
|
||||
}, {});
|
||||
}
|
||||
|
||||
export function isValidPackage(pack: IPackage): boolean {
|
||||
const today = new Date(new Date(Date.now()).toUTCString()).setHours(0, 0, 0, 0);
|
||||
return pack !== null && new Date(pack.dataDate).getTime() <= today
|
||||
|
Reference in New Issue
Block a user