11import Link from 'next/link' ;
22import { twMerge } from 'tailwind-merge' ;
33import prisma from '../utils/prisma' ;
4- import { getGlobalCounts } from '../utils/globalCounts ' ;
4+ import { getGlobalCounts } from '@teerank/teerank ' ;
55import { formatInteger } from '../utils/format' ;
66import { encodeString } from '../utils/encoding' ;
7+ import redis from '../utils/redis' ;
78
89export const metadata = {
910 title : 'Teerank' ,
@@ -88,8 +89,7 @@ export default async function Index() {
8889 players ,
8990 clans ,
9091 gameTypes ,
91- gameTypesCount ,
92- { playerCount, clanCount } ,
92+ globalCounts ,
9393 ] = await Promise . all ( [
9494 prisma . player . findMany ( {
9595 select : {
@@ -128,8 +128,7 @@ export default async function Index() {
128128 take : 3 ,
129129 } ) ,
130130
131- prisma . gameType . count ( ) ,
132- getGlobalCounts ( ) ,
131+ getGlobalCounts ( redis ) ,
133132 ] ) ;
134133
135134 return (
@@ -141,7 +140,7 @@ export default async function Index() {
141140 < RankCard
142141 title = "Players"
143142 titleHref = "/all"
144- count = { playerCount }
143+ count = { globalCounts . players }
145144 rankings = { players . map ( ( player ) => player . name ) }
146145 formatRankingHref = { ( playerName ) =>
147146 `/player/${ encodeString ( playerName ) } `
@@ -150,15 +149,15 @@ export default async function Index() {
150149 < RankCard
151150 title = "Clans"
152151 titleHref = "/all/clans"
153- count = { clanCount }
152+ count = { globalCounts . clans }
154153 rankings = { clans . map ( ( clan ) => clan . name ) }
155154 formatRankingHref = { ( clanName ) => `/clan/${ encodeString ( clanName ) } ` }
156155 />
157156 < RankCard
158157 title = "Gametypes"
159158 titleHref = "/gametypes"
160- count = { gameTypesCount }
161- rankings = { gameTypes . map ( ( gameTypes ) => gameTypes . name ) }
159+ count = { globalCounts . gameTypes }
160+ rankings = { gameTypes . map ( ( gameType ) => gameType . name ) }
162161 formatRankingHref = { ( gameType ) =>
163162 `/gametype/${ encodeString ( gameType ) } `
164163 }
0 commit comments