@dhyasama/totem-models 11.5.0 → 11.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Interaction.js +3 -3
- package/lib/Organization.js +48 -0
- package/package.json +5 -5
package/lib/Interaction.js
CHANGED
|
@@ -196,13 +196,13 @@ module.exports = function(mongoose, config) {
|
|
|
196
196
|
if (!mongoose.Types.ObjectId.isValid(customerId)) { return cb(new Error('customerId is not a valid ObjectId'), null); }
|
|
197
197
|
|
|
198
198
|
const self = this;
|
|
199
|
-
const startDate = options.startDate
|
|
200
|
-
const endDate = options.endDate
|
|
199
|
+
const startDate = options.startDate ? moment(options.startDate).toDate() : moment().subtract(20, 'years').startOf('day').toDate();
|
|
200
|
+
const endDate = options.endDate ? moment(options.endDate).toDate() : new Date();
|
|
201
201
|
|
|
202
202
|
self.aggregate([
|
|
203
203
|
{
|
|
204
204
|
$match: {
|
|
205
|
-
totemCustomerId: customerId,
|
|
205
|
+
totemCustomerId: mongoose.Types.ObjectId(customerId),
|
|
206
206
|
startTime: {
|
|
207
207
|
$gte: startDate,
|
|
208
208
|
$lte: endDate
|
package/lib/Organization.js
CHANGED
|
@@ -1655,6 +1655,54 @@ module.exports = function(mongoose, config) {
|
|
|
1655
1655
|
|
|
1656
1656
|
};
|
|
1657
1657
|
|
|
1658
|
+
Organization.statics.getDocumentsForOrgs = function getDocumentsForOrgs(orgIds, customerId, startDate, endDate, options, cb) {
|
|
1659
|
+
|
|
1660
|
+
const self = this;
|
|
1661
|
+
|
|
1662
|
+
if (!cb) {
|
|
1663
|
+
throw new Error('cb is required');
|
|
1664
|
+
}
|
|
1665
|
+
if (!orgIds) {
|
|
1666
|
+
return cb(new Error('orgIds is required'), null);
|
|
1667
|
+
}
|
|
1668
|
+
if (!options) {
|
|
1669
|
+
return cb(new Error('options is required'), null);
|
|
1670
|
+
}
|
|
1671
|
+
if (!customerId) {
|
|
1672
|
+
return cb(new Error('customerId is required'), null);
|
|
1673
|
+
}
|
|
1674
|
+
if (!startDate) {
|
|
1675
|
+
return cb(new Error('startDate is required'), null);
|
|
1676
|
+
}
|
|
1677
|
+
if (!endDate) {
|
|
1678
|
+
return cb(new Error('endDate is required'), null);
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
let query = self
|
|
1682
|
+
.find( {'_id': { $in : orgIds } } )
|
|
1683
|
+
.select('_id documents')
|
|
1684
|
+
.populate({
|
|
1685
|
+
path: 'documents',
|
|
1686
|
+
match: {
|
|
1687
|
+
customer: customerId,
|
|
1688
|
+
createdOn: { $gte: startDate, $lte: endDate }
|
|
1689
|
+
},
|
|
1690
|
+
})
|
|
1691
|
+
|
|
1692
|
+
query.exec(function(err, result) {
|
|
1693
|
+
|
|
1694
|
+
if (err) { return cb(err, null); }
|
|
1695
|
+
|
|
1696
|
+
result = _.filter(result, function(org) {
|
|
1697
|
+
return org.documents.length > 0;
|
|
1698
|
+
});
|
|
1699
|
+
|
|
1700
|
+
return cb(null, result);
|
|
1701
|
+
|
|
1702
|
+
});
|
|
1703
|
+
|
|
1704
|
+
};
|
|
1705
|
+
|
|
1658
1706
|
Organization.statics.getFlags = function getFlags(orgid, options, cb) {
|
|
1659
1707
|
|
|
1660
1708
|
const self = this;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhyasama/totem-models",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.6.0",
|
|
4
4
|
"author": "Jason Reynolds",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"description": "Models for Totem platform",
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"awesome-phonenumber": "^1.0.14",
|
|
21
21
|
"bluebird": "^3.7.2",
|
|
22
22
|
"escape-string-regexp": "^1.0.5",
|
|
23
|
-
"moment": "^2.
|
|
23
|
+
"moment": "^2.30.1",
|
|
24
24
|
"mongoose-deep-populate": "^3.2.0",
|
|
25
25
|
"range_check": "^1.4.0",
|
|
26
26
|
"request": "^2.88.0",
|
|
27
27
|
"underscore": "^1.13.6",
|
|
28
|
-
"validator": "^13.
|
|
28
|
+
"validator": "^13.11.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"mocha": "^10.
|
|
31
|
+
"mocha": "^10.3.0",
|
|
32
32
|
"mocha-mongoose": "^1.2.0",
|
|
33
|
-
"mongoose": "^5.13.
|
|
33
|
+
"mongoose": "^5.13.22",
|
|
34
34
|
"should": "^11.1.1"
|
|
35
35
|
}
|
|
36
36
|
}
|