From 67e16ea7dd7151a5aa48486c64c543be37082c39 Mon Sep 17 00:00:00 2001 From: Thomas Scholtes Date: Fri, 1 Mar 2024 16:13:44 +0100 Subject: [PATCH] Consolidate and optimize data fetching for ProjectCard We consolidate the code that fetches the data for `ProjectCard` in one module, adjacent to the `ProjectCard` component. We also consolidate all the data into one interface to simplify the component API. With the data loading in one place we can eliminate duplicate code and a handful of helper functions. The consolidation also allows us to discover some optimizations to fetching: We parallelize requests and we use the commit detail endpoint instead of the commit list endpoint. For the latter to pay off, we need to deploy caching to the API. --- src/components/ProjectCard.svelte | 39 ++++++++---------- src/components/ProjectCard.ts | 38 ++++++++++++++++++ src/lib/commit.ts | 7 ---- src/lib/projects.ts | 36 ----------------- src/views/home/Index.svelte | 66 ++++++++++--------------------- src/views/nodes/View.svelte | 24 +++++------ src/views/nodes/router.ts | 31 ++++++--------- 7 files changed, 94 insertions(+), 147 deletions(-) create mode 100644 src/components/ProjectCard.ts diff --git a/src/components/ProjectCard.svelte b/src/components/ProjectCard.svelte index ff6f02b35..5740d826b 100644 --- a/src/components/ProjectCard.svelte +++ b/src/components/ProjectCard.svelte @@ -1,32 +1,25 @@