@optimiser/common 1.0.317 → 1.0.319

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.
Files changed (2) hide show
  1. package/dist/lib/utility.js +22 -12
  2. package/package.json +1 -1
@@ -1007,7 +1007,7 @@ function SyncFieldInSameCollection(objectName, objectIDs, db) {
1007
1007
  var _this = this;
1008
1008
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1009
1009
  return __generator(this, function (_a) {
1010
- console.log("succass");
1010
+ console.log("success");
1011
1011
  try {
1012
1012
  db.collection("ObjectSchema").findOne({ 'Name': objectName }, function (err, objectSchema) {
1013
1013
  return __awaiter(this, void 0, void 0, function () {
@@ -3812,20 +3812,30 @@ exports.SyncUserLicenceConsumedCount = SyncUserLicenceConsumedCount;
3812
3812
  */
3813
3813
  function BroadCastEventToAllCompanyUsers(params) {
3814
3814
  try {
3815
- params.db.collection('User').find({
3816
- IsActive: true,
3817
- UserStatus: constants_1.default.USER_STATUS.ACTIVE
3818
- }, {
3819
- projection: { "_id": 1 }
3820
- }).toArray(function (err, res) {
3815
+ var aggregateArry = [];
3816
+ aggregateArry.push({
3817
+ $match: {
3818
+ 'IsActive': true,
3819
+ 'UserStatus': constants_1.default.USER_STATUS.ACTIVE
3820
+ }
3821
+ });
3822
+ if (params.Match != undefined) {
3823
+ aggregateArry.push({
3824
+ $match: params.Match
3825
+ });
3826
+ }
3827
+ aggregateArry.push({
3828
+ $project: { '_id': 1 }
3829
+ });
3830
+ params.db.collection('User').aggregate(aggregateArry, { "allowDiskUse": true }).toArray(function (err, usersData) {
3821
3831
  if (err) {
3822
3832
  console.log("Error while sending notification " + (params.EventName || "") + " to all company users. ==>", err);
3823
3833
  return;
3824
3834
  }
3825
- else if (res && res.length > 0) {
3826
- for (var i = 0; i < res.length; i++) {
3835
+ else if (usersData && usersData.length > 0) {
3836
+ for (var i = 0; i < usersData.length; i++) {
3827
3837
  //not sending notification to sender
3828
- if (params.UserID && params.UserID.toString() == res[i]._id.toString()) {
3838
+ if (params.UserID && params.UserID.toString() == usersData[i]._id.toString()) {
3829
3839
  continue;
3830
3840
  }
3831
3841
  //params.userID to handle
@@ -3837,9 +3847,9 @@ function BroadCastEventToAllCompanyUsers(params) {
3837
3847
  var socketObjectData = {
3838
3848
  eventType: eventItem.EventName,
3839
3849
  data: eventItem.EventData,
3840
- userId: res[i]._id.toString()
3850
+ userId: usersData[i]._id.toString()
3841
3851
  };
3842
- //socketUtility.TriggerSockerEvent(req, res[i]._id.toString(), eventName, data);
3852
+ //socketUtility.TriggerSockerEvent(req, usersData[i]._id.toString(), eventName, data);
3843
3853
  params.event.CreateEvent(null, null, { SocketObj: socketObjectData }).then(function (socketResult) {
3844
3854
  if (socketResult) {
3845
3855
  console.log("Success");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.317",
3
+ "version": "1.0.319",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {