caelum0x 2b68bde5d5 Predikt: full Polymarket-style prediction market — web + mobile + on-chain + bots
Working tree is now the canonical repo. Off-chain play-money + trustless on-chain
(FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution,
mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 23:29:50 +03:00

53 lines
1.3 KiB
TypeScript

import { league_user_info } from 'common/leagues'
import { convertSQLtoTS, tsToMillis } from 'common/supabase/utils'
import { db } from './db'
export async function getLeagueInfo(userId: string, season: number) {
const { data } = await db
.from('user_league_info')
.select('*')
.eq('user_id', userId)
.eq('season', season)
.limit(1)
if (data && data.length > 0) {
return data[0]
}
return null
}
export async function getLeagueRows(season: number) {
const { data: rows } = await db
.from('user_league_info')
.select('*')
.filter('season', 'eq', season)
.order('mana_earned', { ascending: false })
return (rows ?? []) as league_user_info[]
}
export async function getLeagueChats(season: number) {
const { data: rows } = await db
.from('league_chats')
.select('*')
.eq('season', season)
return (rows ?? []).map((r) => ({
...r,
ownerId: r.owner_id,
channelId: r.channel_id,
createdTime: new Date(r.created_time).getTime(),
}))
}
export async function getOwnedLeagueChats(season: number, ownerId: string) {
const { data: rows } = await db
.from('league_chats')
.select('*')
.eq('season', season)
.eq('owner_id', ownerId)
return (rows ?? []).map((r) =>
convertSQLtoTS(r, {
created_time: tsToMillis as any,
})
)
}