diff --git a/client/src/modules/Lobby/components/Confetti/index.tsx b/client/src/modules/Lobby/components/Confetti/index.tsx index 264c40c..6a0a7cb 100644 --- a/client/src/modules/Lobby/components/Confetti/index.tsx +++ b/client/src/modules/Lobby/components/Confetti/index.tsx @@ -5,16 +5,11 @@ import { CONFETTI_PARTICLE_COUNT } from 'src/constants'; type ConfettiProps = {}; const Confetti: FC = () => { - const refAnimationInstance: any = useRef(null); - - const getInstance = useCallback((instance: any) => { - refAnimationInstance.current = instance; - }, []); + const refAnimationInstance = useRef(null); const makeShot = useCallback((position: number, particleRatio: number, opts: any) => { - if (!refAnimationInstance.current) return; - setTimeout(() => { + if (!refAnimationInstance.current) return; refAnimationInstance.current({ ...opts, origin: { y: position }, @@ -118,8 +113,8 @@ const Confetti: FC = () => { return ( (refAnimationInstance.current = ref)} + className="pointer-events-none fixed left-0 top-0 z-50 h-full w-full" /> ); }; diff --git a/client/src/modules/Lobby/index.tsx b/client/src/modules/Lobby/index.tsx index 5f7d21f..fb90dcd 100644 --- a/client/src/modules/Lobby/index.tsx +++ b/client/src/modules/Lobby/index.tsx @@ -6,7 +6,6 @@ import { disconnectSocket, joinLobby, sendMessage } from '@services/lobby'; import { useRouter } from 'next/router'; import { FC, useEffect, useMemo, useState } from 'react'; import Chat from '../../components/shared/Chat'; -import Dino from './components/Dino'; import Participants from './components/Participants'; import { Status } from '@models/enums'; import { DateTime } from 'luxon'; @@ -84,7 +83,7 @@ const Lobby: FC = ({ discussion }) => { {!discussion && ( <> - {mounted() && } + {/* {mounted() && } */} )} {discussion && ( diff --git a/server/src/modules/challenge/challenge.service.ts b/server/src/modules/challenge/challenge.service.ts index 4083e15..fd94469 100644 --- a/server/src/modules/challenge/challenge.service.ts +++ b/server/src/modules/challenge/challenge.service.ts @@ -46,7 +46,31 @@ export class ChallengeService { } async getPlacements(challengeId: string) { - return await this.dataService.queries.findChallengePlacements(challengeId); + const teamFinishRankings = await this.dataService.queries.findChallengeTeamFinishRankings( + challengeId, + ); + const placements = []; + for (const teamFinishRanking of teamFinishRankings) { + const placement = { + participants: [], + submission: null, + ...teamFinishRanking, + }; + const team = await this.dataService.teams.findById(teamFinishRanking.teamId, { + populate: '*', + }); + const submission = await this.dataService.submissions.findOne( + { challengeId, teamId: teamFinishRanking.teamId }, + { sort: { date: 'asc' } }, + ); + + placement.participants = team.participants; + placement.submission = submission; + + placements.push(placement); + } + + return placements; } async participate(userId: string, challengeId: string) { diff --git a/server/src/modules/providers/ottoman/ottoman.queries.ts b/server/src/modules/providers/ottoman/ottoman.queries.ts index 786bccb..66b1090 100644 --- a/server/src/modules/providers/ottoman/ottoman.queries.ts +++ b/server/src/modules/providers/ottoman/ottoman.queries.ts @@ -34,14 +34,6 @@ export class OttomanQueries { return result.rows[0]; } - async findWinners(challengeId: string) { - const result = await this._query(queries.findWinners, { - parameters: { CHALLENGE_ID: challengeId }, - }); - - return result.rows; - } - async findChallengeTeamFinishRankings(challengeId: string) { const result = await this._query(queries.findChallengeTeamFinishRankings, { parameters: { CHALLENGE_ID: challengeId }, @@ -58,26 +50,6 @@ export class OttomanQueries { }); } - async findChallengePlacements(challengeId: string) { - const result = await this._query(queries.findChallengePlacements, { - parameters: { CHALLENGE_ID: challengeId }, - }); - - const placements = []; - - result.rows.forEach(({ date, teamId, submission, participants }) => { - const mappedParticipants = participants.map((participant) => participant[bucketName]); - placements.push({ - date, - teamId, - submission, - participants: mappedParticipants, - }); - }); - - return placements; - } - async appendChallengeToUser(userId: string, challenge: UserChallenge) { await this._query(queries.appendChallengeToUser, { parameters: { USER_ID: userId, CHALLENGE: challenge }, diff --git a/server/src/modules/providers/ottoman/schemas/queries.ts b/server/src/modules/providers/ottoman/schemas/queries.ts index 4431640..2a55059 100644 --- a/server/src/modules/providers/ottoman/schemas/queries.ts +++ b/server/src/modules/providers/ottoman/schemas/queries.ts @@ -90,11 +90,6 @@ GROUP BY q1.id, difficulty, problem`; -const findWinners = ` -SELECT MAX([runtime, teamId])[0] as runtime, MAX([runtime, teamId])[1] as teamId FROM ${bucketName} -where type = 'submission' and challengeId = $CHALLENGE_ID -group by teamId order by runtime desc limit 3`; - const findChallengeTeamFinishRankings = ` SELECT MIN([date, teamId])[0] as date, MIN([date, teamId])[1] as teamId FROM ${bucketName} where type = 'submission' and status = 3 and challengeId = $CHALLENGE_ID @@ -107,29 +102,6 @@ SET points = points + $POINTS WHERE type = 'user' and id = $USER_ID `; -const findChallengePlacements = ` -SELECT MIN([date, teamId])[0] AS date, - MIN([date, teamId])[1] AS teamId, - participants, - submission -FROM ${bucketName} submission -LET team = ( - SELECT participants - FROM ${bucketName} q2 - WHERE type = 'team' - AND id = submission.teamId), -participants = ( - SELECT * - FROM ${bucketName} where type = 'user' and id in team[0].participants) -WHERE type = 'submission' - AND status = 3 - AND challengeId = $CHALLENGE_ID -GROUP BY teamId, - participants, - submission -ORDER BY date ASC -`; - const appendChallengeToUser = ` Update ${bucketName} set challenges = ARRAY_APPEND(challenges, $CHALLENGE) where type = 'user' and id = $USER_ID @@ -257,10 +229,8 @@ const findDraftArticles = ` export const queries = { findChallenges, findChallenge, - findWinners, findChallengeTeamFinishRankings, addPointsToUser, - findChallengePlacements, appendChallengeToUser, appendProblemToUser, findProblems,