Skip to content

Commit

Permalink
feat: add resolved and pending in workspace and method report
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMaruchu committed Aug 16, 2019
1 parent 9dbd574 commit 733bb37
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions src/base/facets.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,25 +234,46 @@ export const SERVICE_TYPE_FACET = {

export const WORKSPACE_FACET = {
workspaces: [
{ $sortByCount: '$method.workspace' },
{
$group: {
_id: '$method.workspace',
count: { $sum: 1 },
pending: { $sum: '$pending' },
resolved: { $sum: '$resolved' },
},
},
{
$project: {
_id: 0,
name: '$_id',
count: 1,
pending: 1,
resolved: 1,
},
},
{ $sort: { count: -1 } },
],
};

export const REPORTING_METHOD_FACET = {
methods: [
{ $sortByCount: '$method.name' },
{
$group: {
_id: '$method.name',
count: { $sum: 1 },
pending: { $sum: '$pending' },
resolved: { $sum: '$resolved' },
},
},
{
$project: {
name: '$_id',
count: 1,
pending: 1,
resolved: 1,
},
},
{ $sort: { count: -1 } },
],
};

Expand All @@ -276,3 +297,24 @@ export const LEADERSBOARD_FACET = {
},
],
};

export const ASSIGNEE_LEADERSBOARD_FACET = {
assignees: [
{
$group: {
_id: '$$assignee._id',
pending: { $sum: '$pending' },
resolved: { $sum: '$resolved' },
count: { $sum: 1 },
name: { $first: '$operator.name' },
email: { $first: '$operator.email' },
phone: { $first: '$operator.phone' },
},
},
{
$sort: {
count: -1,
},
},
],
};

0 comments on commit 733bb37

Please sign in to comment.