mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-02-26 20:09:21 -05:00
Remove user followers in search-users
This commit is contained in:
@@ -20,15 +20,15 @@ export const searchUsers: APIHandler<'search-users'> = async (props, auth) => {
|
||||
const pg = createSupabaseDirectClient()
|
||||
|
||||
const offset = page * limit
|
||||
const userId = auth?.uid
|
||||
const searchFollowersSQL = getSearchUserSQL({ term, offset, limit, userId })
|
||||
// const userId = auth?.uid
|
||||
// const searchFollowersSQL = getSearchUserSQL({ term, offset, limit, userId })
|
||||
const searchAllSQL = getSearchUserSQL({ term, offset, limit })
|
||||
const [followers, all] = await Promise.all([
|
||||
pg.map(searchFollowersSQL, null, convertUser),
|
||||
const [all] = await Promise.all([
|
||||
// pg.map(searchFollowersSQL, null, convertUser),
|
||||
pg.map(searchAllSQL, null, convertUser),
|
||||
])
|
||||
|
||||
return uniqBy([...followers, ...all], 'id')
|
||||
return uniqBy([...all], 'id')
|
||||
.map(toUserAPIResponse)
|
||||
.slice(0, limit)
|
||||
}
|
||||
@@ -39,17 +39,18 @@ function getSearchUserSQL(props: {
|
||||
limit: number
|
||||
userId?: string // search only this user's followers
|
||||
}) {
|
||||
const { term, userId } = props
|
||||
const { term } = props
|
||||
|
||||
return renderSql(
|
||||
userId
|
||||
? [
|
||||
select('users.*'),
|
||||
from('users'),
|
||||
join('user_follows on user_follows.follow_id = users.id'),
|
||||
where('user_follows.user_id = $1', [userId]),
|
||||
]
|
||||
: [select('*'), from('users')],
|
||||
// userId
|
||||
// ? [
|
||||
// select('users.*'),
|
||||
// from('users'),
|
||||
// join('user_follows on user_follows.follow_id = users.id'),
|
||||
// where('user_follows.user_id = $1', [userId]),
|
||||
// ]
|
||||
// :
|
||||
[select('*'), from('users')],
|
||||
term
|
||||
? [
|
||||
where(
|
||||
|
||||
Reference in New Issue
Block a user