Skip to content

Commit

Permalink
Improves performance of search method (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
pushchris authored Dec 9, 2024
1 parent f4b78be commit 4899668
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/platform/src/core/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export default class Model {
// If sort is provided, order by that first, then by id
// for consistency
qb.orderBy(sort!, direction)
.orderBy('id', direction),
.orderBy(`${this.tableName}.id`, direction),
)
.when(!!cursor, qb => {
// To allow for sorting, `since` may contain either just
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/src/lists/ListController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ router.delete('/:listId', async ctx => {

router.get('/:listId/users', async ctx => {
const searchSchema = SearchSchema('listUserSearchSchema', {
sort: 'id',
sort: 'user_list.id',
direction: 'desc',
})
const params = extractQueryParams(ctx.query, searchSchema)
Expand Down
4 changes: 2 additions & 2 deletions apps/platform/src/lists/ListService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ export const getList = async (id: number, projectId: number) => {
}

export const getListUsers = async (id: number, params: PageParams, projectId: number) => {
return await User.search(
return await UserList.search(
{ ...params, fields: ['email', 'phone'], mode: 'exact' },
b => b.rightJoin('user_list', 'user_list.user_id', 'users.id')
b => b.leftJoin('users', 'user_list.user_id', 'users.id')
.where('project_id', projectId)
.where('list_id', id)
.select('users.*', 'user_list.created_at'),
Expand Down

0 comments on commit 4899668

Please sign in to comment.