fix: wrong month stats and db cache undefined handling

This commit is contained in:
Samuel 2024-12-18 18:27:25 +01:00
parent ee5d986972
commit ec1ea5cfe8
4 changed files with 54 additions and 67 deletions

View file

@ -142,7 +142,9 @@ export const cached = <T extends unknown[], R, TT>(fn: (...args: T) => R, self?:
isPromise = promisified == newValue;
void promisified.then((result) => {
cache.set(cacheName, cacheKey, result);
if (result !== undefined) {
cache.set(cacheName, cacheKey, result);
}
});
return newValue;

View file

@ -57,8 +57,7 @@ export const createMessageStatsSources = (
person[message.fromRecipientId] += 1;
// increment the message count of the message's month for this recipient
// months are an array from 0 - 11
month[messageDate.getMonth() - 1][message.fromRecipientId] += 1;
month[messageDate.getMonth()][message.fromRecipientId] += 1;
// biome-ignore lint/style/noNonNullAssertion: <explanation>
const dateStatsEntry = date.find(({ date }) => isSameDay(date, messageDate))!;