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>
44 lines
1018 B
TypeScript
44 lines
1018 B
TypeScript
import { groupBy, mapValues } from 'lodash'
|
|
import { runScript } from 'run-script'
|
|
import {
|
|
addToLeagueIfNotInOne,
|
|
getUsersNotInLeague,
|
|
} from 'shared/generate-leagues'
|
|
import { SupabaseDirectClient } from 'shared/supabase/init'
|
|
|
|
if (require.main === module) {
|
|
runScript(async ({ pg }) => {
|
|
const userIds = await getUsersNotInLeague(pg, 1)
|
|
console.log('userIds', userIds)
|
|
const divisions = []
|
|
for (const userId of userIds) {
|
|
divisions.push((await addToLeagueIfNotInOne(pg, userId)).division)
|
|
console.log(
|
|
'Added user',
|
|
userId,
|
|
'to league',
|
|
divisions[divisions.length - 1]
|
|
)
|
|
}
|
|
console.log(
|
|
mapValues(
|
|
groupBy(divisions, (d) => d),
|
|
(d) => d.length
|
|
)
|
|
)
|
|
})
|
|
}
|
|
|
|
const _reassignBots = (pg: SupabaseDirectClient) => {
|
|
return pg.none(
|
|
`update leagues
|
|
set division = 4,
|
|
cohort = 'bots'
|
|
where user_id in (
|
|
select id from users
|
|
where is_bot = true
|
|
limit 40
|
|
)`
|
|
)
|
|
}
|