From 259f56bd2668979a5a7f4065faa0751746178e81 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Fri, 7 Nov 2025 23:17:16 +0100 Subject: [PATCH] Fix typescript / linting warnings --- backend/api/src/get-messages-count.ts | 2 +- backend/api/src/search-users.ts | 50 ++++++++------------ backend/api/src/send-search-notifications.ts | 2 +- backend/api/src/serve.ts | 2 +- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/backend/api/src/get-messages-count.ts b/backend/api/src/get-messages-count.ts index ff3ea806..9dce65b7 100644 --- a/backend/api/src/get-messages-count.ts +++ b/backend/api/src/get-messages-count.ts @@ -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( ` diff --git a/backend/api/src/search-users.ts b/backend/api/src/search-users.ts index 2024439c..3ecef033 100644 --- a/backend/api/src/search-users.ts +++ b/backend/api/src/search-users.ts @@ -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) ) diff --git a/backend/api/src/send-search-notifications.ts b/backend/api/src/send-search-notifications.ts index 8d5ec1fd..9d8a0014 100644 --- a/backend/api/src/send-search-notifications.ts +++ b/backend/api/src/send-search-notifications.ts @@ -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 + const { _orderBy, ...filters } = (row.search_filters ?? {}) as Record const props = { ...filters, skipId: row.creator_id, diff --git a/backend/api/src/serve.ts b/backend/api/src/serve.ts index 40976cbf..ed08307c 100644 --- a/backend/api/src/serve.ts +++ b/backend/api/src/serve.ts @@ -40,4 +40,4 @@ const startupProcess = async () => { webSocketListen(httpServer, '/ws') } -startupProcess().then(r => log('Server started successfully')) +startupProcess().then(_r => log('Server started successfully'))