Skip to content

Commit

Permalink
Merge branch 'main' into ingawei/twomba
Browse files Browse the repository at this point in the history
  • Loading branch information
ingawei committed Jul 31, 2024
2 parents 999b6ff + 7141460 commit 63fab64
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions backend/scripts/run-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { getServiceAccountCredentials, loadSecretsToEnv } from 'common/secrets'
import {
createSupabaseClient,
createSupabaseDirectClient,
SupbaseDirectClientTimeout,
SupabaseDirectClientTimeout,
} from 'shared/supabase/init'

initAdmin()

export const runScript = async (
main: (services: {
db: SupabaseClient
pg: SupbaseDirectClientTimeout
pg: SupabaseDirectClientTimeout
firestore: admin.firestore.Firestore
}) => Promise<any> | any
) => {
Expand Down
4 changes: 2 additions & 2 deletions backend/shared/src/importance-score.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
SupabaseDirectClient,
SupbaseDirectClientTimeout,
SupabaseDirectClientTimeout,
} from 'shared/supabase/init'
import { SupabaseClient } from 'common/supabase/utils'
import {
Expand All @@ -27,7 +27,7 @@ export const MIN_IMPORTANCE_SCORE = 0.1

export async function calculateImportanceScore(
db: SupabaseClient,
pg: SupbaseDirectClientTimeout,
pg: SupabaseDirectClientTimeout,
readOnly = false,
rescoreAll = false
) {
Expand Down
8 changes: 4 additions & 4 deletions backend/shared/src/supabase/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ pgp.pg.types.setTypeParser(20, (value) => parseInt(value, 10)) // int8.
pgp.pg.types.setTypeParser(1700, parseFloat) // numeric

pgp.pg.types.setTypeParser(1082, (value) => value) // date (not timestamp! has no time info so we just parse as string)
export type SupbaseDirectClientTimeout = IDatabase<{}, IClient> & {
export type SupabaseDirectClientTimeout = IDatabase<{}, IClient> & {
timeout: TimeoutTask
}
export type SupabaseTransaction = ITask<{}>
export type SupabaseDirectClient =
| SupbaseDirectClientTimeout
| SupabaseDirectClientTimeout
| SupabaseTransaction

export function getInstanceId() {
Expand Down Expand Up @@ -82,11 +82,11 @@ type TimeoutTask = <T>(
) => Promise<T>

// Use one connection to avoid WARNING: Creating a duplicate database object for the same connection.
let pgpDirect: SupbaseDirectClientTimeout | null = null
let pgpDirect: SupabaseDirectClientTimeout | null = null
export function createSupabaseDirectClient(
instanceId?: string,
password?: string
): SupbaseDirectClientTimeout {
): SupabaseDirectClientTimeout {
if (pgpDirect) return pgpDirect
instanceId = instanceId ?? getInstanceId()
if (!instanceId) {
Expand Down
4 changes: 2 additions & 2 deletions backend/shared/src/supabase/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sortBy } from 'lodash'
import { pgp, SupabaseDirectClient, SupbaseDirectClientTimeout } from './init'
import { pgp, SupabaseDirectClient, SupabaseDirectClientTimeout } from './init'
import { DataFor, Tables, TableName, Column, Row } from 'common/supabase/utils'

export async function getIds<T extends TableName>(
Expand Down Expand Up @@ -41,7 +41,7 @@ export async function bulkUpdate<
ColumnValues extends Tables[T]['Update'],
Row extends Tables[T]['Row']
>(
db: SupbaseDirectClientTimeout,
db: SupabaseDirectClientTimeout,
table: T,
idFields: (string & keyof Row)[],
values: ColumnValues[],
Expand Down

0 comments on commit 63fab64

Please sign in to comment.