Skip to content

Commit

Permalink
React 19 form upgrades (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
tydolla00 authored Dec 26, 2024
1 parent 31a9777 commit be4cb0f
Show file tree
Hide file tree
Showing 29 changed files with 583 additions and 410 deletions.
6 changes: 4 additions & 2 deletions next.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const nextConfig = {
import { NextConfig } from "next";

const nextConfig: NextConfig = {
// experimental: { reactCompiler: true },
images: {
remotePatterns: [
{ protocol: "https", hostname: "i.ytimg.com" },
{ protocol: "https", hostname: "assets.xboxservices.com" },
{ protocol: "https", hostname: "static.wikia.nocookie.net" },
],
},
Expand Down
108 changes: 108 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"next-auth": "^5.0.0-beta.25",
"next-themes": "^0.4.4",
"posthog-js": "^1.203.1",
"posthog-node": "^4.3.2",
"react": "^19.0.0",
"react-day-picker": "^8.10.1",
"react-dom": "^19.0.0",
Expand Down
1 change: 1 addition & 0 deletions prisma/scripts/testbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ async function getAllTimeMKRankings() {
console.log("Player Stats", playerStats);
}

// ! TODO Can we remove this?
// async function showSetStatsByPlayerByRace(mkSession: EnrichedSession[]) {
// // Group Stats For A Set By Player
// for (const session of mkSession) {
Expand Down
16 changes: 15 additions & 1 deletion src/app/(routes)/(groups)/games/[slug]/_functions/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getSumPerStat,
} from "../../../../../../../prisma/lib/games";
import { StatNames } from "../../../../../../../prisma/lib/utils";
import PostHogClient from "@/lib/posthog";

export const getRLStats = async (playerId: number) =>
await Promise.all([
Expand Down Expand Up @@ -77,6 +78,7 @@ export const calcMostPerPlacing = async (
) => {
const sessions = await getMatchesPerGame(gameId, statName);
const members = new Map<string, MembersPerPosition>();
const posthog = PostHogClient();

for (const session of sessions) {
for (const set of session.sets) {
Expand All @@ -85,6 +87,10 @@ export const calcMostPerPlacing = async (
for (const ps of match.playerSessions) {
const pos = Number(ps.playerStats[0].value);
if (isNaN(pos)) {
posthog.capture({
event: `NaN called in calcMostPerPlacing val: ${pos}`,
distinctId: new Date().toUTCString(),
});
console.log("Not a number", pos);
continue;
}
Expand Down Expand Up @@ -135,6 +141,7 @@ export const calcMostPerPlacing = async (
7: val[7] || 0,
8: val[8] || 0,
}));
posthog.shutdown();
return data;
};

Expand All @@ -146,19 +153,26 @@ export const calcMostPerPlacing = async (
*/
export const calcStatPerPlayer = async (gameId: number, statName: StatName) => {
const stats = await getStatPerPlayer(gameId, statName);
console.log(stats);
const members = new Map<string, number>();
const posthog = PostHogClient();

for (const { player, value } of stats) {
const val = Number(value);

if (isNaN(val)) {
console.log("Not a number", val); // May want to do some logging
posthog.capture({
event: `NaN called in calculateStatPerPlayer val: ${val}`,
distinctId: new Date().toUTCString(),
});
console.log("Not a number", val);
continue;
}

let member = members.get(player.playerName) || 0;
members.set(player.playerName, member + val);
}
const data = Array.from(members, ([key, val]) => ({ player: key, val }));
posthog.shutdown();
return data;
};
Loading

0 comments on commit be4cb0f

Please sign in to comment.