diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c50d2c..0e454d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixes breakage on `PRO` account link downloads - Fixed width and font size of `ToolTip` component in mobile devices +- Fixed Download counts bug ## [v1.0.1] - 12 January 2024 diff --git a/src/services/download.ts b/src/services/download.ts index 541cb15..e94b09a 100644 --- a/src/services/download.ts +++ b/src/services/download.ts @@ -14,13 +14,11 @@ export type AddDownloadData = { }; export const getIndex = async (id?: AddDownloadData['id']) => { - const maxIndex = await prisma.download.findFirst({ - where: { userId: id }, - select: { index: true }, - orderBy: { index: 'desc' } + const maxIndex = await prisma.download.findMany({ + where: { userId: id } }); - return maxIndex?.index || 0; + return maxIndex?.length || 0; }; export const addDownload = async ({ id, data }: AddDownloadData) => {