Skip to content

Commit

Permalink
chore: add indexes for servedBy
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego committed Aug 22, 2024
1 parent f6351e8 commit e0e3eea
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions apps/meteor/server/models/raw/LivechatRooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export class LivechatRoomsRaw extends BaseRaw<IOmnichannelRoom> implements ILive
{ key: { servedBy: 1 }, sparse: true },
{ key: { 'v.token': 1, 'email.thread': 1 }, sparse: true },
{ key: { 'v._id': 1 }, sparse: true },
{ key: { 't': 1, 'fname': 1, 'servedBy._id': 1, 'onHold': 1 } }, // created with username
{ key: { 't': 1, 'ts': -1, 'servedBy._id': 1, 'onHold': 1 } },
{ key: { 't': 1, 'closedAt': -1, 'servedBy._id': 1, 'onHold': 1 } },
{ key: { t: 1, departmentId: 1, closedAt: 1 }, partialFilterExpression: { closedAt: { $exists: true } } },
{ key: { source: 1 }, sparse: true },
{ key: { departmentAncestors: 1 }, sparse: true },
Expand Down Expand Up @@ -1235,9 +1238,7 @@ export class LivechatRoomsRaw extends BaseRaw<IOmnichannelRoom> implements ILive
const query: Filter<IOmnichannelRoom> = {
t: 'l',
...extraQuery,
...(agents && {
$or: [{ 'servedBy._id': { $in: agents } }, { 'servedBy.username': { $in: agents } }],
}),
...(agents && { 'servedBy._id': { $in: agents } }),
...(roomName && { fname: new RegExp(escapeRegExp(roomName), 'i') }),
...(departmentId && departmentId !== 'undefined' && { departmentId }),
...(open !== undefined && { open: { $exists: open }, onHold: { $ne: true } }),
Expand Down

0 comments on commit e0e3eea

Please sign in to comment.