Advertisement
Altair200333

analysis query

Jul 22nd, 2024
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. [
  2. {
  3. $match: {
  4. createdAt: {
  5. $gte: ISODate("2024-07-15")
  6. }
  7. }
  8. },
  9. {
  10. $addFields: {
  11. tid: {
  12. $toObjectId: "$taskId"
  13. },
  14. cid: {
  15. $toObjectId: "$gptContentId"
  16. },
  17. uid: {
  18. $toObjectId: "$userId"
  19. }
  20. }
  21. },
  22. {
  23. $lookup: {
  24. from: "outreach_prospect_activities",
  25. localField: "tid",
  26. foreignField: "_id",
  27. as: "task"
  28. }
  29. },
  30. {
  31. $lookup: {
  32. from: "gpt3_content",
  33. localField: "cid",
  34. foreignField: "_id",
  35. as: "content"
  36. }
  37. },
  38. {
  39. $lookup: {
  40. from: "users",
  41. localField: "uid",
  42. foreignField: "_id",
  43. as: "user"
  44. }
  45. },
  46. {
  47. $addFields: {
  48. task: {
  49. $first: "$task"
  50. },
  51. content: {
  52. $first: "$content"
  53. },
  54. user: {
  55. $first: "$user"
  56. }
  57. }
  58. },
  59. {
  60. $addFields: {
  61. disposition: "$task.callDisposition",
  62. calledAt: "$task.calledAt",
  63. transcript: "$content.fields.transcript",
  64. aiText: "$content.openAIText",
  65. sequencer: "$user.email"
  66. }
  67. },
  68. {
  69. $group: {
  70. _id: "$_id",
  71. isBridged: {
  72. $first: "$isBridged"
  73. },
  74. isConnected: {
  75. $first: "$isConnected"
  76. },
  77. isFalsePositive: {
  78. $first: "$isFalsePositive"
  79. },
  80. isConversation: {
  81. $first: "$isConversation"
  82. },
  83. taskId: {
  84. $first: "$taskId"
  85. },
  86. callSid: {
  87. $first: "$callSid"
  88. },
  89. sequencer: {
  90. $first: "$sequencer"
  91. },
  92. disposition: {
  93. $first: "$disposition"
  94. },
  95. transcript: {
  96. $accumulator: {
  97. accumulateArgs: ["$transcript"],
  98. init: function () {
  99. return [];
  100. },
  101. accumulate: function (names, name) {
  102. return names.concat(name);
  103. },
  104. merge: function (names1, names2) {
  105. return names1.concat(names2);
  106. },
  107. finalize: function (names) {
  108. return names.join("\n");
  109. },
  110. lang: "js"
  111. }
  112. },
  113. aiText: {
  114. $first: "$aiText"
  115. }
  116. }
  117. }
  118. // {
  119. // $match: {
  120. // "task.callDisposition": "Call Failed"
  121. // }
  122. // }
  123. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement