From 8a8cf810e4a03453b8254eaad56c27529dc107ef Mon Sep 17 00:00:00 2001 From: Fuwn Date: Fri, 22 Dec 2023 06:53:35 -0800 Subject: feat(wrapped): genres and tags --- src/lib/Tools/Wrapped.svelte | 74 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) (limited to 'src/lib/Tools') diff --git a/src/lib/Tools/Wrapped.svelte b/src/lib/Tools/Wrapped.svelte index 57ec09b7..0d8f0834 100644 --- a/src/lib/Tools/Wrapped.svelte +++ b/src/lib/Tools/Wrapped.svelte @@ -10,7 +10,7 @@ fullActivityHistory, activityHistory as getActivityHistory } from '$lib/AniList/activity.js'; - import { Type, mediaListCollection, type Media } from '$lib/AniList/media.js'; + import { Type, mediaListCollection, type Media, mediaCover } from '$lib/AniList/media.js'; import anime from '../../stores/anime.js'; import lastPruneTimes from '../../stores/lastPruneTimes.js'; import manga from '../../stores/manga.js'; @@ -50,6 +50,7 @@ let excludedKeywordsInput = ''; let excludedKeywords: string[] = []; let useFullActivityHistory = false; + let topGenresTags = true; $: { if (browser && mounted) { @@ -344,6 +345,17 @@ const pruneFullYear = async () => { await database.activities.bulkDelete((await database.activities.toArray()).map((m) => m.page)); }; + + const mergeArraySort = (a: any, b: any) => [...a, ...b].sort((a, b) => b.meanScore - a.meanScore); + + const randomCoverFromTop10 = ( + statistics: { anime: any; manga: any }, + mode: 'tags' | 'genres' + ) => { + const top = mergeArraySort(statistics.anime[mode], statistics.manga[mode]); + + return mediaCover(top[Math.floor(Math.random() * top.length)].mediaIds[0]); + }; {#if currentUserIdentity.id === -2} @@ -470,6 +482,64 @@ + {#if topGenresTags} +
+
+
+ {#await randomCoverFromTop10(wrapped.statistics, 'genres') then cover} + Highest Rated Genre Cover + {/await} +
+ Highest Rated Genres +
    + {#each mergeArraySort(wrapped.statistics.anime.genres, wrapped.statistics.manga.genres).slice(0, highestRatedCount) as genre} +
  1. + + {genre.genre}: {genre.meanScore}% + +
  2. + {/each} +
+
+
+
+
+
+ {#await randomCoverFromTop10(wrapped.statistics, 'tags') then cover} + Highest Rated Tag Cover + {/await} +
+ Highest Rated Tags +
    + {#each mergeArraySort(wrapped.statistics.anime.tags, wrapped.statistics.manga.tags).slice(0, highestRatedCount) as tag} +
  1. + + {tag.tag.name}: {tag.meanScore}% + +
  2. + {/each} +
+
+
+
+
+ {/if} {#if !disableActivityHistory}
@@ -501,6 +571,8 @@ Enable background transparency
Enable light mode
+ + Enable top genres and tags
Disable activity history
{#if !disableActivityHistory} -- cgit v1.2.3