From b70c248cadc62e29f7b95463754c3dfc7dae01d9 Mon Sep 17 00:00:00 2001 From: Type-Style Date: Fri, 19 Jul 2024 15:06:02 +0200 Subject: [PATCH] [Fix] #94, refactor-ignore logic (multiline) (#95) Serverside: When writing entry, the most recent previous entry is checked wether to be ignored. Also if more than 2 items already exist meaning writing is preparing at least the 3rd entry, we recalculate distances and timing if previousItems are ignored. Frontend: In order to benefit and get the recent information that a previous item is being ignored, frontEnd askes for the current item again and merges it and following items. Remember the most recent item can never be ignored due to policy. Maybe there is no further writing, so I want to have the latest datapoint. --- src/client/components/Map.tsx | 15 ++++++++++----- src/client/components/Status.tsx | 2 +- src/client/pages/Start.tsx | 24 +++++++++++++++++++----- src/models/entry.ts | 29 +++++++++++++++++++++++------ src/scripts/ignore.ts | 4 ++-- src/tests/integration.test.ts | 19 +++++++++++++------ views/index.ejs | 6 +++--- 7 files changed, 71 insertions(+), 28 deletions(-) diff --git a/src/client/components/Map.tsx b/src/client/components/Map.tsx index 3eb782a..abfe558 100644 --- a/src/client/components/Map.tsx +++ b/src/client/components/Map.tsx @@ -23,7 +23,9 @@ function Map({ entries }: { entries: Models.IEntry[] }) { if (!entries?.length) { return No Data to be displayed } + const lastEntry = entries.at(-1); + const cleanEntries = entries.filter((entry) => !entry.ignore); return ( @@ -32,11 +34,14 @@ function Map({ entries }: { entries: Models.IEntry[] }) { attribution='© OpenStreetMap contributors' url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" /> - - - {JSON.stringify(lastEntry, null, 2)} - - + {cleanEntries.map((entry) => + + +
{JSON.stringify(entry, null, 2)}
+
+
+ )} +
) } diff --git a/src/client/components/Status.tsx b/src/client/components/Status.tsx index 48a04bc..5c1991e 100644 --- a/src/client/components/Status.tsx +++ b/src/client/components/Status.tsx @@ -44,7 +44,7 @@ function Map({ entries }: { entries: Models.IEntry[] }) { return No Data to be displayed } const statusData = getStatusData(entries); - const lastEntry = entries.at(-1); + //const lastEntry = entries.at(-1); return (