From 2824e3d1b7bf620bd258f7bd11b0a8d5b0eacd07 Mon Sep 17 00:00:00 2001 From: Yasamato Date: Sat, 30 Dec 2023 13:44:51 +0100 Subject: [PATCH 1/4] Add typecheck against null --- lib/db/views.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/db/views.ts b/lib/db/views.ts index a0cfbabb..8ec28614 100644 --- a/lib/db/views.ts +++ b/lib/db/views.ts @@ -51,8 +51,9 @@ export async function getLastViews(type: Types, n: number) { await Promise.all( sorted.map(async (s) => { const data = await findOneTyped(type, s.contentId) - - data.views = s.count + if (data !== null) { + data.views = s.count + } return data }) ) From d083bdc3203078c143942e356b88d993c7174e19 Mon Sep 17 00:00:00 2001 From: Yasamato Date: Sat, 30 Dec 2023 13:59:50 +0100 Subject: [PATCH 2/4] Revert "Hide ping till fixed (#79)" This reverts commit f907c7eaef27c35056ff7d4193bb1fa52f8bdfaa. --- components/data/OnlineStatus.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/data/OnlineStatus.tsx b/components/data/OnlineStatus.tsx index 628dc8da..4204398a 100644 --- a/components/data/OnlineStatus.tsx +++ b/components/data/OnlineStatus.tsx @@ -47,7 +47,7 @@ const OnlineStatus: FC = ({ item }) => { } return ( -
+ <> setShow(true)} @@ -64,7 +64,7 @@ const OnlineStatus: FC = ({ item }) => { close={() => setShow(false)} /> )} -
+ ) } From 1d84a1e9a12a005dbd334f7178ed8420ba67d0d3 Mon Sep 17 00:00:00 2001 From: Yasamato Date: Sat, 30 Dec 2023 14:00:02 +0100 Subject: [PATCH 3/4] Update [id].tsx --- pages/item/[id].tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pages/item/[id].tsx b/pages/item/[id].tsx index c54dbd3f..04f8857b 100644 --- a/pages/item/[id].tsx +++ b/pages/item/[id].tsx @@ -27,6 +27,7 @@ import { Column } from '../../types/Column' import { Collection } from '../../types/Collection' import DeleteButton from '../../components/buttons/DeleteButton' import { faStar } from '@fortawesome/free-solid-svg-icons/faStar' +import { findOneTyped, getAllTyped } from '../../lib/db/dbTyped' type Props = { item: Item @@ -359,7 +360,7 @@ const Item: FC = ({ item, columns, collections }) => { export default Item export async function getStaticPaths() { - const items = await getItems() + const items = await getAllTyped(Types.item) const paths = items.map((i) => { return { params: { @@ -375,7 +376,7 @@ export async function getStaticPaths() { } export async function getStaticProps({ params }) { - const item = await getItem(params.id) + const item = await findOneTyped(Types.item, params.id) as Item if (!item) { return { notFound: true, From 26d1d0cc746f9a67da7c3ac8ba954ae8a008bc80 Mon Sep 17 00:00:00 2001 From: Yasamato Date: Sat, 30 Dec 2023 14:01:29 +0100 Subject: [PATCH 4/4] Update views.ts --- lib/db/views.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/db/views.ts b/lib/db/views.ts index 8ec28614..48dc658a 100644 --- a/lib/db/views.ts +++ b/lib/db/views.ts @@ -27,6 +27,7 @@ export async function getLastViews(type: Types, n: number) { .limit(n) .toArray() ) + console.log('Found', data.length, 'entries in views table for', type) // count what has been popular recently let accumulated = {}