Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- $match: {
- createdAt: {
- $gte: ISODate("2024-07-15")
- }
- }
- },
- {
- $addFields: {
- tid: {
- $toObjectId: "$taskId"
- },
- cid: {
- $toObjectId: "$gptContentId"
- },
- uid: {
- $toObjectId: "$userId"
- }
- }
- },
- {
- $lookup: {
- from: "outreach_prospect_activities",
- localField: "tid",
- foreignField: "_id",
- as: "task"
- }
- },
- {
- $lookup: {
- from: "gpt3_content",
- localField: "cid",
- foreignField: "_id",
- as: "content"
- }
- },
- {
- $lookup: {
- from: "users",
- localField: "uid",
- foreignField: "_id",
- as: "user"
- }
- },
- {
- $addFields: {
- task: {
- $first: "$task"
- },
- content: {
- $first: "$content"
- },
- user: {
- $first: "$user"
- }
- }
- },
- {
- $addFields: {
- disposition: "$task.callDisposition",
- calledAt: "$task.calledAt",
- transcript: "$content.fields.transcript",
- aiText: "$content.openAIText",
- sequencer: "$user.email"
- }
- },
- {
- $group: {
- _id: "$_id",
- isBridged: {
- $first: "$isBridged"
- },
- isConnected: {
- $first: "$isConnected"
- },
- isFalsePositive: {
- $first: "$isFalsePositive"
- },
- isConversation: {
- $first: "$isConversation"
- },
- taskId: {
- $first: "$taskId"
- },
- callSid: {
- $first: "$callSid"
- },
- sequencer: {
- $first: "$sequencer"
- },
- disposition: {
- $first: "$disposition"
- },
- transcript: {
- $accumulator: {
- accumulateArgs: ["$transcript"],
- init: function () {
- return [];
- },
- accumulate: function (names, name) {
- return names.concat(name);
- },
- merge: function (names1, names2) {
- return names1.concat(names2);
- },
- finalize: function (names) {
- return names.join("\n");
- },
- lang: "js"
- }
- },
- aiText: {
- $first: "$aiText"
- }
- }
- }
- // {
- // $match: {
- // "task.callDisposition": "Call Failed"
- // }
- // }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement