diff options
| author | Fuwn <[email protected]> | 2023-11-22 17:55:21 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-11-22 17:55:21 -0800 |
| commit | f0af82a648eaa16868d823e84ccfad279bfdfbcc (patch) | |
| tree | 8a32e3744685147f0dac8ff21c1aa393961f9590 /src/lib | |
| parent | feat(wrapped): move calculations to media list (diff) | |
| download | due.moe-f0af82a648eaa16868d823e84ccfad279bfdfbcc.tar.xz due.moe-f0af82a648eaa16868d823e84ccfad279bfdfbcc.zip | |
fix(wrapped): cap activity counts at year
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/AniList/wrapped.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/lib/AniList/wrapped.ts b/src/lib/AniList/wrapped.ts index bd700101..8a3b3f57 100644 --- a/src/lib/AniList/wrapped.ts +++ b/src/lib/AniList/wrapped.ts @@ -42,9 +42,11 @@ const profileActivities = async (user: AniListAuthorisation, identity: UserIdent activities(userId: ${identity.id}, type_in: [ TEXT, MESSAGE ]) { ... on TextActivity { type + createdAt } ... on MessageActivity { type + createdAt } } pageInfo { @@ -70,8 +72,19 @@ const profileActivities = async (user: AniListAuthorisation, identity: UserIdent } return { - statusCount: pages.flat().filter((activity) => activity.type == 'TEXT').length, - messageCount: pages.flat().filter((activity) => activity.type == 'MESSAGE').length + statusCount: pages + .flat() + .filter( + (activity) => + activity.type == 'TEXT' && activity.createdAt > Math.floor(Date.now() / 1000) - 31556952 + ).length, + messageCount: pages + .flat() + .filter( + (activity) => + activity.type == 'MESSAGE' && + activity.createdAt > Math.floor(Date.now() / 1000) - 31556952 + ).length }; }; |