Skip to content

Commit

Permalink
fix: if no date is available, use the current year
Browse files Browse the repository at this point in the history
  • Loading branch information
JanssenBrm committed Nov 25, 2023
1 parent 01ab215 commit ed39ecc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions functions/src/pubsub/cropsar.pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ export const getCropSARDates = (actions: Action[]): [string, string] | undefined
if (dates.length > 0) {
return [`${dates[0]}-01-01`, `${dates[dates.length - 1]}-12-31`];
} else {
return undefined;
const now = moment().year();
return [`${now}-01-01`, `${now}-12-31`];
}
};

const calculateAllCropSAR = async () => {
export const calculateAllCropSAR = async () => {
console.log('Starting calculation of CropSAR');

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

0 comments on commit ed39ecc

Please sign in to comment.