diff --git a/messages/en.json b/messages/en.json index 80a9c00..4c06d26 100644 --- a/messages/en.json +++ b/messages/en.json @@ -37,5 +37,8 @@ "lastAddedSidebar": "Last Added", "getLucky": "Get Lucky", "randomPull": "Random Pull", - "highlightAlbum": "Highlight Soundtrack" + "highlightAlbum": "Highlight Soundtrack", + "ostCount": "Soundtrack Count", + "animOsts": "Animation Soundtracks", + "gameOsts": "Game Soundtracks" } \ No newline at end of file diff --git a/package.json b/package.json index b42206a..8da89ec 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "start": "npm run dev", "dev": "astro dev", - "build": "npm run paraglide:compile && prisma generate && astro build", + "build": "npm run paraglide:compile && prisma generate --sql && astro build", "preview": "astro preview", "paraglide:compile": "paraglide-js compile --project ./project.inlang --outdir ./src\\paraglide" }, @@ -15,7 +15,7 @@ "@astrojs/rss": "4.0.11", "@astrojs/tailwind": "^6.0.0", "@inlang/paraglide-astro": "^0.2.2", - "@prisma/client": "^6.2.1", + "@prisma/client": "^6.3.1", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "astro": "5.1.5", @@ -46,6 +46,6 @@ "neostandard": "^0.11.6", "prettier": "^3.3.3", "prettier-config-standard": "^7.0.0", - "prisma": "^6.2.1" + "prisma": "^6.3.1" } } diff --git a/prisma/schema.prisma b/prisma/schema.prisma index bbdab2c..88f7ad6 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,5 +1,6 @@ generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" + previewFeatures = ["typedSql"] } datasource db { diff --git a/prisma/sql/getAlbumCount.sql b/prisma/sql/getAlbumCount.sql new file mode 100644 index 0000000..82d1769 --- /dev/null +++ b/prisma/sql/getAlbumCount.sql @@ -0,0 +1,5 @@ +SELECT `categoryName`, COUNT(*) as "count" +FROM `Album_Category`, `albums` +WHERE `Album_Category`.`albumId` = `albums`.`id` +AND `albums`.`status` = "show" +GROUP BY `categoryName`; \ No newline at end of file diff --git a/src/components/Sidebar.astro b/src/components/Sidebar.astro index 355e90e..753f953 100644 --- a/src/components/Sidebar.astro +++ b/src/components/Sidebar.astro @@ -10,6 +10,7 @@ import twitter from 'img/socials/twitter.png' import SidebarSection from './sidebar/SidebarSection.astro' import Highlight from './sidebar/Highlight.astro' import AlbumBox from './AlbumBox.astro' +import AlbumCount from './sidebar/AlbumCount.astro' const listClass = 'uppercase text-3xl font-semibold w-full text-center py-3 hover:bg-dark-hover hover:text-cyan-400 hover:underline' @@ -47,5 +48,8 @@ const listClass = + + + diff --git a/src/components/sidebar/AlbumCount.astro b/src/components/sidebar/AlbumCount.astro new file mode 100644 index 0000000..00be1f0 --- /dev/null +++ b/src/components/sidebar/AlbumCount.astro @@ -0,0 +1,28 @@ +--- +import prismaClient from 'utils/prisma-client' +import * as m from 'paraglide/messages.js' + +import SidebarSection from './SidebarSection.astro' + +import { getAlbumCount } from '@prisma/client/sql' + +const albumCount = await prismaClient.albums.count({ where: { status: 'show' } }) +const categoryRows = await prismaClient.$queryRawTyped(getAlbumCount()) + +const categories = categoryRows.reduce( + (acc, currentValue) => { + // @ts-ignore + acc[currentValue.categoryName] = currentValue.count + return acc + }, + { Animation: 0, Game: 0 } +) +--- + + + {m.ostCount()}: {albumCount} + + {m.animOsts}: {categories.Animation} + {m.gameOsts}: {categories.Game} + + diff --git a/yarn.lock b/yarn.lock index dd7378d..1ba415c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1408,46 +1408,46 @@ resolved "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz" integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA== -"@prisma/client@^6.2.1": - version "6.2.1" - resolved "https://registry.npmjs.org/@prisma/client/-/client-6.2.1.tgz" - integrity sha512-msKY2iRLISN8t5X0Tj7hU0UWet1u0KuxSPHWuf3IRkB4J95mCvGpyQBfQ6ufcmvKNOMQSq90O2iUmJEN2e5fiA== +"@prisma/client@^6.3.1": + version "6.3.1" + resolved "https://registry.yarnpkg.com/@prisma/client/-/client-6.3.1.tgz#4e4b05b27f4541ea541a601c57a8ada10b526848" + integrity sha512-ARAJaPs+eBkemdky/XU3cvGRl+mIPHCN2lCXsl5Vlb0E2gV+R6IN7aCI8CisRGszEZondwIsW9Iz8EJkTdykyA== -"@prisma/debug@6.2.1": - version "6.2.1" - resolved "https://registry.npmjs.org/@prisma/debug/-/debug-6.2.1.tgz" - integrity sha512-0KItvt39CmQxWkEw6oW+RQMD6RZ43SJWgEUnzxN8VC9ixMysa7MzZCZf22LCK5DSooiLNf8vM3LHZm/I/Ni7bQ== +"@prisma/debug@6.3.1": + version "6.3.1" + resolved "https://registry.yarnpkg.com/@prisma/debug/-/debug-6.3.1.tgz#08730461dab4fe147efa70637952b942dc1961b5" + integrity sha512-RrEBkd+HLZx+ydfmYT0jUj7wjLiS95wfTOSQ+8FQbvb6vHh5AeKfEPt/XUQ5+Buljj8hltEfOslEW57/wQIVeA== -"@prisma/engines-version@6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69": - version "6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69" - resolved "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69.tgz" - integrity sha512-7tw1qs/9GWSX6qbZs4He09TOTg1ff3gYsB3ubaVNN0Pp1zLm9NC5C5MZShtkz7TyQjx7blhpknB7HwEhlG+PrQ== +"@prisma/engines-version@6.3.0-17.acc0b9dd43eb689cbd20c9470515d719db10d0b0": + version "6.3.0-17.acc0b9dd43eb689cbd20c9470515d719db10d0b0" + resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-6.3.0-17.acc0b9dd43eb689cbd20c9470515d719db10d0b0.tgz#a9651d70ed1198dd37780a44da0e9db7c547c7dc" + integrity sha512-R/ZcMuaWZT2UBmgX3Ko6PAV3f8//ZzsjRIG1eKqp3f2rqEqVtCv+mtzuH2rBPUC9ujJ5kCb9wwpxeyCkLcHVyA== -"@prisma/engines@6.2.1": - version "6.2.1" - resolved "https://registry.npmjs.org/@prisma/engines/-/engines-6.2.1.tgz" - integrity sha512-lTBNLJBCxVT9iP5I7Mn6GlwqAxTpS5qMERrhebkUhtXpGVkBNd/jHnNJBZQW4kGDCKaQg/r2vlJYkzOHnAb7ZQ== +"@prisma/engines@6.3.1": + version "6.3.1" + resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-6.3.1.tgz#9d4d10bff8af4a56f3545b3a109a1c98d1e1d0d2" + integrity sha512-sXdqEVLyGAJ5/iUoG/Ea5AdHMN71m6PzMBWRQnLmhhOejzqAaEr8rUd623ql6OJpED4s/U4vIn4dg1qkF7vGag== dependencies: - "@prisma/debug" "6.2.1" - "@prisma/engines-version" "6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69" - "@prisma/fetch-engine" "6.2.1" - "@prisma/get-platform" "6.2.1" + "@prisma/debug" "6.3.1" + "@prisma/engines-version" "6.3.0-17.acc0b9dd43eb689cbd20c9470515d719db10d0b0" + "@prisma/fetch-engine" "6.3.1" + "@prisma/get-platform" "6.3.1" -"@prisma/fetch-engine@6.2.1": - version "6.2.1" - resolved "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.2.1.tgz" - integrity sha512-OO7O9d6Mrx2F9i+Gu1LW+DGXXyUFkP7OE5aj9iBfA/2jjDXEJjqa9X0ZmM9NZNo8Uo7ql6zKm6yjDcbAcRrw1A== +"@prisma/fetch-engine@6.3.1": + version "6.3.1" + resolved "https://registry.yarnpkg.com/@prisma/fetch-engine/-/fetch-engine-6.3.1.tgz#104a1b919890ef5d6f69a1705d4f986e039ef206" + integrity sha512-HOf/0umOgt+/S2xtZze+FHKoxpVg4YpVxROr6g2YG09VsI3Ipyb+rGvD6QGbCqkq5NTWAAZoOGNL+oy7t+IhaQ== dependencies: - "@prisma/debug" "6.2.1" - "@prisma/engines-version" "6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69" - "@prisma/get-platform" "6.2.1" + "@prisma/debug" "6.3.1" + "@prisma/engines-version" "6.3.0-17.acc0b9dd43eb689cbd20c9470515d719db10d0b0" + "@prisma/get-platform" "6.3.1" -"@prisma/get-platform@6.2.1": - version "6.2.1" - resolved "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.2.1.tgz" - integrity sha512-zp53yvroPl5m5/gXYLz7tGCNG33bhG+JYCm74ohxOq1pPnrL47VQYFfF3RbTZ7TzGWCrR3EtoiYMywUBw7UK6Q== +"@prisma/get-platform@6.3.1": + version "6.3.1" + resolved "https://registry.yarnpkg.com/@prisma/get-platform/-/get-platform-6.3.1.tgz#2fbf7c5a59b42a5df488bdc6d683303c08b02d34" + integrity sha512-AYLq6Hk9xG73JdLWJ3Ip9Wg/vlP7xPvftGBalsPzKDOHr/ImhwJ09eS8xC2vNT12DlzGxhfk8BkL0ve2OriNhQ== dependencies: - "@prisma/debug" "6.2.1" + "@prisma/debug" "6.3.1" "@rollup/pluginutils@^5.1.3": version "5.1.4" @@ -5752,12 +5752,12 @@ prettier@^3.3.3: resolved "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz" integrity sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew== -prisma@^6.2.1: - version "6.2.1" - resolved "https://registry.npmjs.org/prisma/-/prisma-6.2.1.tgz" - integrity sha512-hhyM0H13pQleQ+br4CkzGizS5I0oInoeTw3JfLw1BRZduBSQxPILlJLwi+46wZzj9Je7ndyQEMGw/n5cN2fknA== +prisma@^6.3.1: + version "6.3.1" + resolved "https://registry.yarnpkg.com/prisma/-/prisma-6.3.1.tgz#c97f3ad3be6aacd90dde437857ca347abd51559e" + integrity sha512-JKCZWvBC3enxk51tY4TWzS4b5iRt4sSU1uHn2I183giZTvonXaQonzVtjLzpOHE7qu9MxY510kAtFGJwryKe3Q== dependencies: - "@prisma/engines" "6.2.1" + "@prisma/engines" "6.3.1" optionalDependencies: fsevents "2.3.3"