Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
ingawei committed Jul 12, 2024
2 parents 0bf7d69 + b9c37aa commit 3525a93
Show file tree
Hide file tree
Showing 9 changed files with 602 additions and 823 deletions.
5 changes: 3 additions & 2 deletions backend/api/src/unresolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { broadcastUpdatedAnswers } from 'shared/websockets/helpers'
import { convertAnswer } from 'common/supabase/contracts'
import { updateContract } from 'shared/supabase/contracts'
import { FieldVal } from 'shared/supabase/utils'
import { convertTxn } from 'common/supabase/txns'

const TXNS_PR_MERGED_ON = 1675693800000 // #PR 1476

Expand Down Expand Up @@ -180,7 +181,7 @@ const undoResolution = async (
and ($2 is null or (data->'data'->>'payoutStartTime')::numeric = $2)
and ($3 is null or data ->'data'->>'answerId' = $3)`,
[contractId, maxSpicePayoutStartTime, answerId],
(r) => r.data as ContractProduceSpiceTxn
(r) => convertTxn(r) as ContractProduceSpiceTxn
)

log('Reverting spice txns ' + spiceTxnsToRevert.length)
Expand Down Expand Up @@ -220,7 +221,7 @@ const undoResolution = async (
and ($2 is null or (data->'data'->>'payoutStartTime')::numeric = $2)
and ($3 is null or data ->'data'->>'answerId' = $3)`,
[contractId, maxSpicePayoutStartTime, answerId],
(r) => r.data as ContractOldResolutionPayoutTxn
(r) => convertTxn(r) as ContractOldResolutionPayoutTxn
)

log('Reverting mana txns ' + manaTxns.length)
Expand Down
5 changes: 3 additions & 2 deletions backend/scripts/reclaim-mana-undo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { runScript } from './run-script'
import { runTxn } from 'shared/src/txn/run-txn'
import { ReclaimManaTxn } from 'common/src/txn'
import { convertTxn } from 'common/supabase/txns'

if (require.main === module) {
runScript(async ({ pg, firestore }) => {
Expand Down Expand Up @@ -29,12 +30,12 @@ if (require.main === module) {
({ from_id }) => from_id as string
)
const reclaimTxns = await pg.map(
`SELECT data FROM txns
`SELECT * FROM txns
WHERE
from_id IN ($1:list)
AND category = 'RECLAIM_MANA'`,
[usersIdsToUndoReclaim],
(r) => r.data as ReclaimManaTxn
(r) => convertTxn(r) as ReclaimManaTxn
)

for (const reclaimTxn of reclaimTxns) {
Expand Down
3 changes: 2 additions & 1 deletion backend/scripts/regen-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ async function getFunctions(pg: SupabaseDirectClient) {
FROM pg_proc
WHERE
pronamespace = 'public'::regnamespace
and prokind = 'f'`
and prokind = 'f'
ORDER BY proname asc`
)
return rows.filter((f) => !f.definition.includes(`'$libdir/`))
}
Expand Down
7 changes: 0 additions & 7 deletions backend/shared/src/supabase/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ export async function getIds<T extends TableName>(
return db.map('select id from $1~', [table], (r) => r.id as string)
}

export async function getAll<T extends TableName>(
db: SupabaseDirectClient,
table: T
) {
return db.map('select data from $1~', [table], (r) => r.data as DataFor<T>)
}

export async function insert<
T extends TableName,
ColumnValues extends Tables[T]['Insert']
Expand Down
Loading

0 comments on commit 3525a93

Please sign in to comment.