diff options
| author | Fuwn <[email protected]> | 2024-01-13 21:02:42 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-01-13 21:02:42 -0800 |
| commit | 8aa88dc9c0772971b274d6146c0bdcf92f806f9f (patch) | |
| tree | 1f41761155519fdfbba099e2ad2122b6972ecd88 /src | |
| parent | feat(tools): add private message (diff) | |
| download | due.moe-8aa88dc9c0772971b274d6146c0bdcf92f806f9f.tar.xz due.moe-8aa88dc9c0772971b274d6146c0bdcf92f806f9f.zip | |
fix(wrapped): limit activities to year
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/AniList/wrapped.ts | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/AniList/wrapped.ts b/src/lib/AniList/wrapped.ts index 5190dfdf..72c81cd8 100644 --- a/src/lib/AniList/wrapped.ts +++ b/src/lib/AniList/wrapped.ts @@ -48,8 +48,9 @@ export interface Wrapped { const profileActivities = async ( user: AniListAuthorisation, identity: UserIdentity, - now = Date.now() + date = new Date() ) => { + const now = date.getTime(); const get = async (page: number) => await ( await fetch('https://graphql.anilist.co', { @@ -62,7 +63,11 @@ const profileActivities = async ( body: JSON.stringify({ query: `{ Page(page: ${page}) { - activities(userId: ${identity.id}, type_in: [ TEXT, MESSAGE ]) { + activities(userId: ${identity.id}, type_in: [ TEXT, MESSAGE ], createdAt_greater: ${Math.floor( + new Date(date.getFullYear(), 0, 1).getTime() / 1000 + )}, createdAt_lesser: ${Math.floor( + new Date(date.getFullYear(), 7, 1).getTime() / 1000 + )}) { ... on TextActivity { type createdAt @@ -163,7 +168,7 @@ export const wrapped = async ( const { statusCount, messageCount } = await profileActivities( anilistAuthorisation, identity, - new Date(year, 11, 31).getTime() + new Date(year, 11, 31) ); statusCountActivities = statusCount; |