From e6cebd8c46010796809589643abf3c81ea404561 Mon Sep 17 00:00:00 2001 From: diced Date: Sat, 29 Oct 2022 10:52:27 -0700 Subject: [PATCH] fix: update node@18, fix views aggregation, force update stats --- .nvmrc | 2 +- Dockerfile | 11 +++--- package.json | 2 +- src/components/File.tsx | 4 +- src/components/pages/Manage/index.tsx | 31 +++++++++++++++ src/pages/api/stats.ts | 55 +++++++++++++++++---------- src/pages/api/user/files.ts | 18 +++++++-- src/pages/api/user/recent.ts | 2 - src/server/util.ts | 6 +-- yarn.lock | 16 ++++---- 10 files changed, 101 insertions(+), 46 deletions(-) diff --git a/.nvmrc b/.nvmrc index 0ff3804..8cf0e41 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -16.16.0 \ No newline at end of file +18.12.0 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8874feb..1d02921 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,15 @@ FROM ghcr.io/diced/prisma-binaries:4.5.x as prisma -FROM alpine:3.16 AS deps +FROM node:alpine3.16 AS deps RUN mkdir -p /prisma-engines WORKDIR /build COPY .yarn .yarn COPY package.json yarn.lock .yarnrc.yml ./ -RUN apk add --no-cache nodejs yarn RUN yarn install --immutable -FROM alpine:3.16 AS builder +FROM node:alpine3.16 AS builder WORKDIR /build COPY --from=prisma /prisma-engines /prisma-engines @@ -21,7 +20,7 @@ ENV PRISMA_QUERY_ENGINE_BINARY=/prisma-engines/query-engine \ PRISMA_CLI_QUERY_ENGINE_TYPE=binary \ PRISMA_CLIENT_ENGINE_TYPE=binary -RUN apk add --no-cache nodejs yarn openssl openssl-dev +RUN apk add --no-cache openssl openssl-dev COPY --from=deps /build/node_modules ./node_modules COPY src ./src @@ -34,7 +33,7 @@ ENV NEXT_TELEMETRY_DISABLED 1 RUN yarn build -FROM alpine:3.16 AS runner +FROM node:alpine3.16 AS runner WORKDIR /zipline COPY --from=prisma /prisma-engines /prisma-engines @@ -45,7 +44,7 @@ ENV PRISMA_QUERY_ENGINE_BINARY=/prisma-engines/query-engine \ PRISMA_CLI_QUERY_ENGINE_TYPE=binary \ PRISMA_CLIENT_ENGINE_TYPE=binary -RUN apk add --no-cache nodejs yarn openssl openssl-dev +RUN apk add --no-cache openssl openssl-dev ENV NODE_ENV production ENV NEXT_TELEMETRY_DISABLED 1 diff --git a/package.json b/package.json index 5459722..c1d9da7 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "@types/cookie": "^0.5.1", "@types/minio": "^7.0.14", "@types/multer": "^1.4.7", - "@types/node": "16.11.68", + "@types/node": "^18.11.7", "@types/react": "^18.0.24", "@types/sharp": "^0.31.0", "cross-env": "^7.0.3", diff --git a/src/components/File.tsx b/src/components/File.tsx index 3fdeccb..9da9cd8 100644 --- a/src/components/File.tsx +++ b/src/components/File.tsx @@ -118,7 +118,7 @@ export default function File({ image, updateImages, disableMediaPreview }) { setOpen(true)} disableMediaPreview={disableMediaPreview} diff --git a/src/components/pages/Manage/index.tsx b/src/components/pages/Manage/index.tsx index 269f3f5..762c2e8 100644 --- a/src/components/pages/Manage/index.tsx +++ b/src/components/pages/Manage/index.tsx @@ -19,6 +19,7 @@ import { randomId, useInterval } from '@mantine/hooks'; import { useModals } from '@mantine/modals'; import { showNotification, updateNotification } from '@mantine/notifications'; import { + CheckIcon, CrossIcon, DeleteIcon, FlameshotIcon, @@ -270,6 +271,25 @@ export default function Manage() { }, }); + const forceUpdateStats = async () => { + const res = await useFetch('/api/stats', 'POST'); + if (res.error) { + showNotification({ + title: 'Error updating stats', + message: res.error, + color: 'red', + icon: , + }); + } else { + showNotification({ + title: 'Updated stats', + message: '', + color: 'green', + icon: , + }); + } + }; + const interval = useInterval(() => getExports(), 30000); useEffect(() => { getExports(); @@ -400,6 +420,17 @@ export default function Manage() { )} + {user.administrator && ( + + Server + + + + + )} + Uploaders