Skip to content

Commit

Permalink
Fixed a bug in helperFunctions where the current month's range was us…
Browse files Browse the repository at this point in the history
…ing the wrong times.
  • Loading branch information
ThomasMcSherry committed Oct 27, 2023
1 parent 285e588 commit 33d23a7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions vinoa-web/lib/utils/helperFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ const getCurrentMonthAsRange = () => {
start.setDate(1);
let end = new Date(start);
end.setMonth(end.getMonth() + 1);

let from = start.toISOString();
from = from.substring(0, from.indexOf('T'));
let to = end.toISOString();
to = to.substring(0, to.indexOf('T'));

return { from, to };
}
};

const getAverageRating= (reviews: Review[]) => {
let sum =0
const getAverageRating = (reviews: Review[]) => {
let sum = 0;
reviews.forEach((review) => {
sum += review.rating;
});
return sum / reviews.length;
}
export { getAverageRating , getCurrentMonthAsRange};
};
export { getAverageRating, getCurrentMonthAsRange };

0 comments on commit 33d23a7

Please sign in to comment.