Skip to content

Commit

Permalink
Add lastUpdate in elo table
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetenstad committed Sep 17, 2024
1 parent adb2a06 commit dfa3758
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/stores/elo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,19 @@ export const useEloStore = defineStore('elo', {
},

async upsertElo(userId: string, gameType: GameType, elo: number) {
await supabase.from('elo').upsert({ id: userId, [gameType]: elo })
await supabase.from('elo').upsert({
id: userId,
[gameType]: elo,
lastUpdate: new Date().toISOString(),
})
},

async fetchPersonalElo() {
const userId = useAuthStore().auth?.id
if (!userId) return
const eloResponse = await supabase
.from('elo')
.select('x01, rtc, killer, skovhugger, cricket')
.select('*')
.eq('id', userId)
if (eloResponse.data?.length) {
this.personalElo = eloResponse.data[0]
Expand Down
3 changes: 3 additions & 0 deletions src/types/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type Database = {
cricket: number | null
id: string
killer: number | null
lastUpdate: string | null
rtc: number | null
skovhugger: number | null
x01: number | null
Expand All @@ -22,6 +23,7 @@ export type Database = {
cricket?: number | null
id: string
killer?: number | null
lastUpdate?: string | null
rtc?: number | null
skovhugger?: number | null
x01?: number | null
Expand All @@ -30,6 +32,7 @@ export type Database = {
cricket?: number | null
id?: string
killer?: number | null
lastUpdate?: string | null
rtc?: number | null
skovhugger?: number | null
x01?: number | null
Expand Down

0 comments on commit dfa3758

Please sign in to comment.