mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-05-11 16:49:28 -04:00
Fix typescript / linting warnings
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import {APIHandler} from './helpers/endpoint'
|
||||
import {createSupabaseDirectClient} from "shared/supabase/init";
|
||||
|
||||
export const getMessagesCount: APIHandler<'get-messages-count'> = async (_, auth) => {
|
||||
export const getMessagesCount: APIHandler<'get-messages-count'> = async (_, _auth) => {
|
||||
const pg = createSupabaseDirectClient()
|
||||
const result = await pg.one(
|
||||
`
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
import { constructPrefixTsQuery } from 'shared/helpers/search'
|
||||
import {
|
||||
from,
|
||||
join,
|
||||
limit,
|
||||
orderBy,
|
||||
renderSql,
|
||||
select,
|
||||
where,
|
||||
} from 'shared/supabase/sql-builder'
|
||||
import { type APIHandler } from './helpers/endpoint'
|
||||
import { convertUser } from 'common/supabase/users'
|
||||
import { createSupabaseDirectClient } from 'shared/supabase/init'
|
||||
import { toUserAPIResponse } from 'common/api/user-types'
|
||||
import { uniqBy } from 'lodash'
|
||||
import {constructPrefixTsQuery} from 'shared/helpers/search'
|
||||
import {from, limit, orderBy, renderSql, select, where,} from 'shared/supabase/sql-builder'
|
||||
import {type APIHandler} from './helpers/endpoint'
|
||||
import {convertUser} from 'common/supabase/users'
|
||||
import {createSupabaseDirectClient} from 'shared/supabase/init'
|
||||
import {toUserAPIResponse} from 'common/api/user-types'
|
||||
import {uniqBy} from 'lodash'
|
||||
|
||||
export const searchUsers: APIHandler<'search-users'> = async (props, auth) => {
|
||||
const { term, page, limit } = props
|
||||
export const searchUsers: APIHandler<'search-users'> = async (props, _auth) => {
|
||||
const {term, page, limit} = props
|
||||
|
||||
const pg = createSupabaseDirectClient()
|
||||
|
||||
const offset = page * limit
|
||||
// const userId = auth?.uid
|
||||
// const searchFollowersSQL = getSearchUserSQL({ term, offset, limit, userId })
|
||||
const searchAllSQL = getSearchUserSQL({ term, offset, limit })
|
||||
const searchAllSQL = getSearchUserSQL({term, offset, limit})
|
||||
const [all] = await Promise.all([
|
||||
// pg.map(searchFollowersSQL, null, convertUser),
|
||||
pg.map(searchAllSQL, null, convertUser),
|
||||
@@ -39,7 +31,7 @@ function getSearchUserSQL(props: {
|
||||
limit: number
|
||||
userId?: string // search only this user's followers
|
||||
}) {
|
||||
const { term } = props
|
||||
const {term} = props
|
||||
|
||||
return renderSql(
|
||||
// userId
|
||||
@@ -50,21 +42,21 @@ function getSearchUserSQL(props: {
|
||||
// where('user_follows.user_id = $1', [userId]),
|
||||
// ]
|
||||
// :
|
||||
[select('*'), from('users')],
|
||||
[select('*'), from('users')],
|
||||
term
|
||||
? [
|
||||
where(
|
||||
`name_username_vector @@ websearch_to_tsquery('english', $1)
|
||||
where(
|
||||
`name_username_vector @@ websearch_to_tsquery('english', $1)
|
||||
or name_username_vector @@ to_tsquery('english', $2)`,
|
||||
[term, constructPrefixTsQuery(term)]
|
||||
),
|
||||
[term, constructPrefixTsQuery(term)]
|
||||
),
|
||||
|
||||
orderBy(
|
||||
`ts_rank(name_username_vector, websearch_to_tsquery($1)) desc,
|
||||
orderBy(
|
||||
`ts_rank(name_username_vector, websearch_to_tsquery($1)) desc,
|
||||
data->>'lastBetTime' desc nulls last`,
|
||||
[term]
|
||||
),
|
||||
]
|
||||
[term]
|
||||
),
|
||||
]
|
||||
: orderBy(`data->'creatorTraders'->'allTime' desc nulls last`),
|
||||
limit(props.limit, props.offset)
|
||||
)
|
||||
|
||||
@@ -53,7 +53,7 @@ export const sendSearchNotifications = async () => {
|
||||
|
||||
for (const row of searches) {
|
||||
if (typeof row.search_filters !== 'object') continue;
|
||||
const { orderBy, ...filters } = (row.search_filters ?? {}) as Record<string, any>
|
||||
const { _orderBy, ...filters } = (row.search_filters ?? {}) as Record<string, any>
|
||||
const props = {
|
||||
...filters,
|
||||
skipId: row.creator_id,
|
||||
|
||||
@@ -40,4 +40,4 @@ const startupProcess = async () => {
|
||||
|
||||
webSocketListen(httpServer, '/ws')
|
||||
}
|
||||
startupProcess().then(r => log('Server started successfully'))
|
||||
startupProcess().then(_r => log('Server started successfully'))
|
||||
|
||||
Reference in New Issue
Block a user