Skip to content

Commit ed39ecc

Browse files
committed
fix: if no date is available, use the current year
1 parent 01ab215 commit ed39ecc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

functions/src/pubsub/cropsar.pubsub.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ export const getCropSARDates = (actions: Action[]): [string, string] | undefined
6666
if (dates.length > 0) {
6767
return [`${dates[0]}-01-01`, `${dates[dates.length - 1]}-12-31`];
6868
} else {
69-
return undefined;
69+
const now = moment().year();
70+
return [`${now}-01-01`, `${now}-12-31`];
7071
}
7172
};
7273

73-
const calculateAllCropSAR = async () => {
74+
export const calculateAllCropSAR = async () => {
7475
console.log('Starting calculation of CropSAR');
7576

7677
const users: string[] = await getPremiumUsers();

0 commit comments

Comments
 (0)