mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Don't display broken streak through the API
This commit is contained in:
parent
30559ba043
commit
86ffa7f0cc
1 changed files with 10 additions and 4 deletions
|
|
@ -70,13 +70,19 @@ async function renderAccount(
|
|||
})) ?? [];
|
||||
|
||||
let streakDays = 0;
|
||||
const streakStart = event.author_stats?.streak_start;
|
||||
const streakEnd = event.author_stats?.streak_end;
|
||||
let streakStart = event.author_stats?.streak_start ?? null;
|
||||
let streakEnd = event.author_stats?.streak_end ?? null;
|
||||
|
||||
if (streakStart && streakEnd) {
|
||||
const broken = nostrNow() - streakEnd > 86400;
|
||||
if (broken) {
|
||||
streakStart = null;
|
||||
streakEnd = null;
|
||||
} else {
|
||||
const delta = streakEnd - streakStart;
|
||||
streakDays = Math.max(Math.ceil(delta / 86400), 1);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
id: pubkey,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue