11import { useFetcher } from '@remix-run/react' ;
2- import { getPlayers } from '~/services/player-service' ;
3- import {
4- getRecent1v1Matches ,
5- revertLatest1v1Match ,
6- } from '~/services/match-service' ;
2+ import { getPlayers as getPlayersNeo4j } from '~/services/player-service-neo4j' ;
3+ import { revertLatest1v1Match } from '~/services/match-service' ;
4+ import { getRecent1v1Matches as getRecent1v1MatchesNeo4j } from '~/services/match-service-neo4j' ;
75import { PageContainerStyling } from './team-duel' ;
86import { typedjson , useTypedLoaderData } from 'remix-typedjson' ;
97import { BASE_ELO } from '~/utils/constants' ;
108
119export const loader = async ( ) => {
12- const players = await getPlayers ( ) ;
13- const recent1v1Matches = await getRecent1v1Matches ( 5 ) ;
10+ const playersNeo4j = await getPlayersNeo4j ( ) ;
11+ const recent1v1MatchesNeo4j = await getRecent1v1MatchesNeo4j ( 5 ) ;
1412
15- return typedjson ( { players, recent1v1Matches } ) ;
13+ return typedjson ( {
14+ playersNeo4j,
15+ recent1v1MatchesNeo4j,
16+ } ) ;
1617} ;
1718
1819export const action = async ( ) => {
@@ -34,9 +35,10 @@ const getRowHighlightClass = (idx: number, matchDate: Date) =>
3435
3536export default function Index ( ) {
3637 const fetcher = useFetcher ( ) ;
37- const { players, recent1v1Matches } = useTypedLoaderData < typeof loader > ( ) ;
38+ const { playersNeo4j, recent1v1MatchesNeo4j } =
39+ useTypedLoaderData < typeof loader > ( ) ;
3840
39- const rankedPlayersSortedOnELODesc = [ ...players ]
41+ const rankedPlayersSortedOnELODesc = [ ...playersNeo4j ]
4042 . filter ( ( a ) => a . currentELO !== BASE_ELO )
4143 . sort ( ( p1 , p2 ) => p2 . currentELO - p1 . currentELO ) ;
4244
@@ -57,13 +59,13 @@ export default function Index() {
5759 </ tr >
5860 </ thead >
5961 < tbody >
60- { recent1v1Matches . map ( ( match , idx ) => (
62+ { recent1v1MatchesNeo4j . map ( ( match , idx ) => (
6163 < tr
6264 key = { match . id }
63- className = { `border-b dark:border-gray-600 ${ getRowHighlightClass ( idx , match . date ) } ` }
65+ className = { `border-b dark:border-gray-600 ${ getRowHighlightClass ( idx , match . createdDatetime ) } ` }
6466 >
6567 < td className = "py-2 dark:text-white" >
66- { match . date . toLocaleString ( 'no-NO' , {
68+ { match . createdDatetime . toLocaleString ( 'no-NO' , {
6769 day : '2-digit' ,
6870 month : 'short' ,
6971 hour : '2-digit' ,
@@ -91,7 +93,7 @@ export default function Index() {
9193 </ td >
9294 < td >
9395 { isLatestMatch ( idx ) &&
94- isMatchLessThan5MinutesOld ( match . date ) && (
96+ isMatchLessThan5MinutesOld ( match . createdDatetime ) && (
9597 < button
9698 onClick = { ( ) => fetcher . submit ( { } , { method : 'post' } ) }
9799 className = "mx-4 rounded bg-blue-600 px-2 py-1 font-bold text-white hover:bg-blue-700 dark:bg-purple-600 dark:hover:bg-purple-800"
@@ -124,9 +126,7 @@ export default function Index() {
124126 < tbody >
125127 { rankedPlayersSortedOnELODesc
126128 . filter (
127- ( a ) =>
128- a . matchesAsWinner . length + a . matchesAsLoser . length > 4 &&
129- ! a . inactive
129+ ( a ) => a . nbMatchesWon + a . nbMatchesLost > 4 && ! a . inactive
130130 )
131131 . map ( ( player ) => (
132132 < tr
@@ -137,11 +137,11 @@ export default function Index() {
137137 { player . name }
138138 </ td >
139139 < td className = "py-2 dark:text-white" >
140- { `${ player . matchesAsWinner . length } ` +
140+ { `${ player . nbMatchesWon } ` +
141141 ( player . winStreak > 0 ? ` (${ player . winStreak } )` : '' ) }
142142 </ td >
143143 < td className = "py-2 dark:text-white" >
144- { player . matchesAsLoser . length }
144+ { player . nbMatchesLost }
145145 </ td >
146146 < td className = "py-2 dark:text-white" > { player . currentELO } </ td >
147147 </ tr >
@@ -162,9 +162,7 @@ export default function Index() {
162162 </ tr >
163163 { rankedPlayersSortedOnELODesc
164164 . filter (
165- ( a ) =>
166- a . matchesAsWinner . length + a . matchesAsLoser . length <= 4 &&
167- ! a . inactive
165+ ( a ) => a . nbMatchesWon + a . nbMatchesLost <= 4 && ! a . inactive
168166 )
169167 . map ( ( player ) => (
170168 < tr
@@ -175,11 +173,11 @@ export default function Index() {
175173 { player . name }
176174 </ td >
177175 < td className = "py-2 dark:text-white" >
178- { `${ player . matchesAsWinner . length } ` +
176+ { `${ player . nbMatchesWon } ` +
179177 ( player . winStreak > 0 ? ` (${ player . winStreak } )` : '' ) }
180178 </ td >
181179 < td className = "py-2 dark:text-white" >
182- { player . matchesAsLoser . length }
180+ { player . nbMatchesLost }
183181 </ td >
184182 < td > </ td >
185183 </ tr >
@@ -210,10 +208,10 @@ export default function Index() {
210208 { player . name }
211209 </ td >
212210 < td className = "py-2 dark:text-white" >
213- { `${ player . matchesAsWinner . length } ` }
211+ { `${ player . nbMatchesWon } ` }
214212 </ td >
215213 < td className = "py-2 dark:text-white" >
216- { player . matchesAsLoser . length }
214+ { player . nbMatchesLost }
217215 </ td >
218216 < td className = "py-2 dark:text-white" > { player . currentELO } </ td >
219217 </ tr >
0 commit comments