tango-app-api-client 3.0.39-dev → 3.0.40-dev

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-client",
3
- "version": "3.0.39-dev",
3
+ "version": "3.0.40-dev",
4
4
  "description": "client",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -25,8 +25,8 @@
25
25
  "mongodb": "^6.3.0",
26
26
  "nodemon": "^3.0.3",
27
27
  "swagger-ui-express": "^5.0.0",
28
- "tango-api-schema": "^2.0.89",
29
- "tango-app-api-middleware": "^1.0.60-dev",
28
+ "tango-api-schema": "^2.0.93",
29
+ "tango-app-api-middleware": "^3.1.9",
30
30
  "winston": "^3.11.0",
31
31
  "winston-daily-rotate-file": "^5.0.0"
32
32
  },
@@ -382,9 +382,18 @@ export async function detailedAllClientCount( req, res ) {
382
382
  {
383
383
  $project: {
384
384
  activeClient: { $cond: [ { $eq: [ '$status', 'active' ] }, 1, 0 ] },
385
- paidClient: { $cond: [ { $in: [ '$planDetails.paymentStatus', [ 'paid', 'unbilled', 'due' ] ] }, 1, 0 ] },
386
- trialClient: { $cond: [ { $eq: [ '$planDetails.paymentStatus', 'trial' ] }, 1, 0 ] },
387
- freeClient: { $cond: [ { $eq: [ '$planDetails.paymentStatus', 'free' ] }, 1, 0 ] },
385
+ paidClient: { $cond: [ { $and: [
386
+ { $eq: [ '$status', 'active' ] },
387
+ { $in: [ '$planDetails.paymentStatus', [ 'paid', 'unbilled', 'due' ] ] },
388
+ ] }, 1, 0 ] },
389
+ trialClient: { $cond: [ { $and: [
390
+ { $eq: [ '$status', 'active' ] },
391
+ { $eq: [ '$planDetails.paymentStatus', 'trial' ] },
392
+ ] }, 1, 0 ] },
393
+
394
+ freeClient: { $cond: [ { $and: [
395
+ { $eq: [ '$status', 'active' ] }, { $eq: [ '$planDetails.paymentStatus', 'free' ] },
396
+ ] }, 1, 0 ] },
388
397
  holdClient: { $cond: [ { $eq: [ '$status', 'hold' ] }, 1, 0 ] },
389
398
  suspendClient: { $cond: [ { $eq: [ '$status', 'suspended' ] }, 1, 0 ] },
390
399
  deactiveClient: { $cond: [ { $eq: [ '$status', 'deactive' ] }, 1, 0 ] },
@@ -404,11 +413,30 @@ export async function detailedAllClientCount( req, res ) {
404
413
 
405
414
  },
406
415
  },
416
+ {
417
+ $project: {
418
+ _id: 0,
419
+ totalCount: 1,
420
+ activeClient: 1,
421
+ paidClient: 1,
422
+ trialClient: 1,
423
+ freeClient: 1,
424
+ holdClient: 1,
425
+ suspendClient: 1,
426
+ deactiveClient: 1,
427
+ activeStoresCount: { $ifNull: [ 0, 0 ] },
428
+ activeCameraCount: { $ifNull: [ 0, 0 ] },
429
+ },
430
+ },
407
431
  ];
408
432
  const result = await aggregateClient( query );
409
- if ( result == 0 ) {
433
+ const activeStores = await countDocumentsStore( { status: 'active' } );
434
+ const activeCameras = await countDocumentsCamera( { isUp: true, isActivated: true } );
435
+ if ( result.length == 0 ) {
410
436
  return res.sendError( 'No Data Found', 204 );
411
437
  }
438
+ result[0].activeStoresCount = activeStores;
439
+ result[0].activeCameraCount = activeCameras;
412
440
  return res.sendSuccess( { result: result } );
413
441
  } catch ( error ) {
414
442
  logger.error( { error: error, function: 'detailedAllClientCount' } );
@@ -994,6 +1022,10 @@ export async function clientList( req, res ) {
994
1022
  );
995
1023
  }
996
1024
  if ( inputData.filterByPaymentStatus ) {
1025
+ if ( inputData.filterByPaymentStatus.includes( 'paid' ) ) {
1026
+ inputData.filterByPaymentStatus.push( ...[ 'unbilled', 'due' ] );
1027
+ }
1028
+
997
1029
  clientQuery.push(
998
1030
  {
999
1031
  $match: {
@@ -40,14 +40,6 @@ export const clientDocs = {
40
40
  description: 'Get list of clients',
41
41
  operationId: 'get-clients',
42
42
  parameters: [
43
- {
44
- in: 'path',
45
- name: 'id',
46
- required: true,
47
- schema: {
48
- type: 'string',
49
- },
50
- },
51
43
  ],
52
44
  responses: {
53
45
  200: { description: 'Success' },
@@ -455,14 +447,6 @@ export const clientDocs = {
455
447
  description: 'Get toatal info about overall clients',
456
448
  operationId: 'detailed-all-client-count',
457
449
  parameters: [
458
- {
459
- in: 'path',
460
- name: 'id',
461
- required: true,
462
- schema: {
463
- type: 'string',
464
- },
465
- },
466
450
  ],
467
451
  responses: {
468
452
  200: { description: 'Success' },
@@ -28,23 +28,25 @@ export function findClient( query, field ) {
28
28
  export async function createAuditQueue( queueName ) {
29
29
  try {
30
30
  const isExist = await getQueueUrl( `${queueName}${appConfig.cloud.aws.sqs.queueType}` );
31
+ logger.info( { message: isExist, function: 'createAuditQueue-isExist' } );
31
32
  if ( isExist.statusCode ) {
32
33
  const addQueue = await createQueue( `${queueName}${appConfig.cloud.aws.sqs.queueType}` );
34
+ logger.info( { message: addQueue.QueueUrl, function: 'addQueue.QueueUrl' } );
33
35
  if ( addQueue.QueueUrl ) {
34
36
  logger.info(
35
37
  'Queueue Created'
36
38
  , { queueName: addQueue.QueueUrl, addQueue },
37
39
  );
38
40
  } else {
39
- logger.error( { error: 'Queue creation failed', function: 'createAuditQueue' } );
41
+ logger.error( { error: 'Queue creation failed', function: 'createAuditQueue-failed' } );
40
42
  }
41
43
  } else {
42
- logger.error( { error: 'Queue already exisit', message: queueName, function: 'createAuditQueue' } );
44
+ logger.error( { error: 'Queue already exisit', message: queueName, function: 'createAuditQueue-alreday exist' } );
43
45
  }
44
46
  return true;
45
47
  } catch ( error ) {
46
48
  logger.error( { error: error, message: queueName, function: 'createAuditQueue' } );
47
- return false;
49
+ return res.sendError( `Queue Doesn't create`, 500 );
48
50
  }
49
51
  }
50
52