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

54 lines
1.2 KiB
TypeScript

import { Json } from 'common/supabase/schema'
import { Row, run, tsToMillis } from 'common/supabase/utils'
import { db } from './db'
export const getUserRating = async (userId: string) => {
const { data } = await db.rpc('get_rating', { user_id: userId }).single()
return data
}
export const getAverageUserRating = async (userId: string) => {
const { data } = await db.rpc('get_average_rating', { user_id: userId })
return data
}
export const getUserReviews = async (userId: string) => {
const { data } = await run(
db
.from('reviews')
.select('*')
.eq('vendor_id', userId)
.order('created_time', { ascending: false })
)
return data.map(convertReview)
}
export const getMyReviewOnContract = async (
contractId: string,
userId: string
) => {
const { data } = await db
.from('reviews')
.select('*')
.eq('market_id', contractId)
.eq('reviewer_id', userId)
.limit(1)
return data?.[0] ? convertReview(data[0]) : null
}
export type Review = {
created_time: number
content: Json
market_id: string
rating: number
reviewer_id: string
vendor_id: string
}
const convertReview = (review: Row<'reviews'>) => ({
...review,
created_time: tsToMillis(review.created_time),
})