Skip to content

Commit

Permalink
improve some queries to use the index
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego committed Aug 22, 2024
1 parent e0e3eea commit c810ef3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions apps/meteor/server/models/raw/LivechatRooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ export class LivechatRoomsRaw extends BaseRaw<IOmnichannelRoom> implements ILive
const match: Document = {
$match: {
't': 'l',
'servedBy.username': { $exists: true },
'servedBy._id': { $exists: true },
'open': true,
'$or': [
{
Expand Down Expand Up @@ -771,7 +771,7 @@ export class LivechatRoomsRaw extends BaseRaw<IOmnichannelRoom> implements ILive
const match: Document = {
$match: {
't': 'l',
'servedBy.username': { $exists: true },
'servedBy._id': { $exists: true },
'open': true,
'onHold': {
$exists: true,
Expand All @@ -797,7 +797,7 @@ export class LivechatRoomsRaw extends BaseRaw<IOmnichannelRoom> implements ILive
$match: {
't': 'l',
'open': { $exists: false },
'servedBy.username': { $exists: true },
'servedBy._id': { $exists: true },
'ts': { $gte: new Date(start) },
'closedAt': { $lte: new Date(end) },
},
Expand Down Expand Up @@ -1054,7 +1054,7 @@ export class LivechatRoomsRaw extends BaseRaw<IOmnichannelRoom> implements ILive
't': 'l',
'ts': { $gte: new Date(start), $lte: new Date(end) },
'responseBy.lastMessageTs': { $exists: true },
'servedBy.ts': { $exists: true },
'servedBy._id': { $exists: true },
},
};
const group = {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/server/models/raw/VoipRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class VoipRoomRaw extends BaseRaw<IVoipRoom> implements IVoipRoomModel {
const query: Filter<IVoipRoom> = {
t: 'v',
...(visitorId && visitorId !== 'undefined' && { 'v._id': visitorId }),
...(agents && { $or: [{ 'servedBy._id': { $in: agents } }, { 'servedBy.username': { $in: agents } }] }),
...(agents && { 'servedBy._id': { $in: agents } }),
};

if (open !== undefined) {
Expand Down

0 comments on commit c810ef3

Please sign in to comment.