mirror of
https://github.com/ershisan99/www.git
synced 2025-12-17 12:34:17 +00:00
remove unused logs
This commit is contained in:
@@ -16,10 +16,10 @@ import type React from 'react'
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
|
||||||
import { GamesTable } from '@/app/(home)/players/[id]/_components/games-table'
|
import { GamesTable } from '@/app/(home)/players/[id]/_components/games-table'
|
||||||
import { TimeZoneProvider } from '@/components/timezone-provider'
|
|
||||||
import { MmrTrendChart } from '@/app/(home)/players/[id]/_components/mmr-trend-chart'
|
import { MmrTrendChart } from '@/app/(home)/players/[id]/_components/mmr-trend-chart'
|
||||||
import { WinrateTrendChart } from '@/app/(home)/players/[id]/_components/winrate-trend-chart'
|
|
||||||
import { OpponentsTable } from '@/app/(home)/players/[id]/_components/opponents-table'
|
import { OpponentsTable } from '@/app/(home)/players/[id]/_components/opponents-table'
|
||||||
|
import { WinrateTrendChart } from '@/app/(home)/players/[id]/_components/winrate-trend-chart'
|
||||||
|
import { TimeZoneProvider } from '@/components/timezone-provider'
|
||||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
||||||
import { Badge } from '@/components/ui/badge'
|
import { Badge } from '@/components/ui/badge'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
@@ -158,7 +158,6 @@ export function UserInfo() {
|
|||||||
const lastVanillaGame = games
|
const lastVanillaGame = games
|
||||||
.filter((game) => game.gameType.toLowerCase() === 'vanilla')
|
.filter((game) => game.gameType.toLowerCase() === 'vanilla')
|
||||||
.at(0)
|
.at(0)
|
||||||
console.log(games)
|
|
||||||
const avgOpponentMmr =
|
const avgOpponentMmr =
|
||||||
games
|
games
|
||||||
.filter(
|
.filter(
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ export function StreamCardClient() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(winsVsOpponent, lossesVsOpponent)
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={'flex items-center justify-between gap-2 font-m6x11'}
|
className={'flex items-center justify-between gap-2 font-m6x11'}
|
||||||
|
|||||||
@@ -22,9 +22,11 @@ export const history_router = createTRPCRouter({
|
|||||||
}),
|
}),
|
||||||
games_per_hour: publicProcedure
|
games_per_hour: publicProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z
|
||||||
groupBy: z.enum(['hour', 'day', 'week', 'month']).default('hour'),
|
.object({
|
||||||
}).optional()
|
groupBy: z.enum(['hour', 'day', 'week', 'month']).default('hour'),
|
||||||
|
})
|
||||||
|
.optional()
|
||||||
)
|
)
|
||||||
.query(async ({ ctx, input }) => {
|
.query(async ({ ctx, input }) => {
|
||||||
const groupBy = input?.groupBy || 'hour'
|
const groupBy = input?.groupBy || 'hour'
|
||||||
@@ -42,45 +44,48 @@ export const history_router = createTRPCRouter({
|
|||||||
const processedGameNums = new Set<number>()
|
const processedGameNums = new Set<number>()
|
||||||
|
|
||||||
// Group games by the selected time unit
|
// Group games by the selected time unit
|
||||||
const gamesByTimeUnit = games.reduce<Record<string, number>>((acc, game) => {
|
const gamesByTimeUnit = games.reduce<Record<string, number>>(
|
||||||
if (!game.gameTime || !game.gameNum) return acc
|
(acc, game) => {
|
||||||
|
if (!game.gameTime || !game.gameNum) return acc
|
||||||
|
|
||||||
// Skip if we've already processed this game number
|
// Skip if we've already processed this game number
|
||||||
if (processedGameNums.has(game.gameNum)) return acc
|
if (processedGameNums.has(game.gameNum)) return acc
|
||||||
|
|
||||||
// Mark this game as processed
|
// Mark this game as processed
|
||||||
processedGameNums.add(game.gameNum)
|
processedGameNums.add(game.gameNum)
|
||||||
|
|
||||||
const date = new Date(game.gameTime)
|
const date = new Date(game.gameTime)
|
||||||
let timeKey: string
|
let timeKey: string
|
||||||
|
|
||||||
switch (groupBy) {
|
switch (groupBy) {
|
||||||
case 'hour':
|
case 'hour':
|
||||||
// Format: YYYY-MM-DD HH:00
|
// Format: YYYY-MM-DD HH:00
|
||||||
timeKey = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:00`
|
timeKey = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:00`
|
||||||
break
|
break
|
||||||
case 'day':
|
case 'day':
|
||||||
// Format: YYYY-MM-DD
|
// Format: YYYY-MM-DD
|
||||||
timeKey = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
|
timeKey = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
|
||||||
break
|
break
|
||||||
case 'week':
|
case 'week':
|
||||||
// Get the first day of the week (Sunday)
|
// Get the first day of the week (Sunday)
|
||||||
const firstDayOfWeek = new Date(date)
|
const firstDayOfWeek = new Date(date)
|
||||||
const day = date.getDay() // 0 = Sunday, 1 = Monday, etc.
|
const day = date.getDay() // 0 = Sunday, 1 = Monday, etc.
|
||||||
firstDayOfWeek.setDate(date.getDate() - day)
|
firstDayOfWeek.setDate(date.getDate() - day)
|
||||||
timeKey = `Week of ${firstDayOfWeek.getFullYear()}-${String(firstDayOfWeek.getMonth() + 1).padStart(2, '0')}-${String(firstDayOfWeek.getDate()).padStart(2, '0')}`
|
timeKey = `Week of ${firstDayOfWeek.getFullYear()}-${String(firstDayOfWeek.getMonth() + 1).padStart(2, '0')}-${String(firstDayOfWeek.getDate()).padStart(2, '0')}`
|
||||||
break
|
break
|
||||||
case 'month':
|
case 'month':
|
||||||
// Format: YYYY-MM
|
// Format: YYYY-MM
|
||||||
timeKey = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}`
|
timeKey = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}`
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
timeKey = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:00`
|
timeKey = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:00`
|
||||||
}
|
}
|
||||||
|
|
||||||
acc[timeKey] = (acc[timeKey] || 0) + 1
|
acc[timeKey] = (acc[timeKey] || 0) + 1
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
},
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
|
||||||
// Convert to array format for chart
|
// Convert to array format for chart
|
||||||
return Object.entries(gamesByTimeUnit).map(([timeUnit, count]) => ({
|
return Object.entries(gamesByTimeUnit).map(([timeUnit, count]) => ({
|
||||||
@@ -155,12 +160,10 @@ function processGameEntry(gameId: number, game_num: number, entry: any) {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
if (!parsedEntry.teams?.[0]?.[0] || !parsedEntry.teams?.[1]?.[0]) {
|
if (!parsedEntry.teams?.[0]?.[0] || !parsedEntry.teams?.[1]?.[0]) {
|
||||||
console.log('skipping game', parsedEntry)
|
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsedEntry.winner === -2) {
|
if (parsedEntry.winner === -2) {
|
||||||
console.log('skipping ongoing game', parsedEntry)
|
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
const player0 = parsedEntry.teams[0][0]
|
const player0 = parsedEntry.teams[0][0]
|
||||||
|
|||||||
Reference in New Issue
Block a user