tango-app-api-infra 3.1.34-beta.41 → 3.1.34-beta.43

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-infra",
3
- "version": "3.1.34-beta.41",
3
+ "version": "3.1.34-beta.43",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -7,6 +7,9 @@ import { aggregateClient, findClient } from '../services/client.service.js';
7
7
  import dayjs from 'dayjs';
8
8
  import { getOpenSearchData } from 'tango-app-api-middleware';
9
9
  import { aggregateUserAssignedStore, findUserAssignedStore } from '../services/userAssignedStore.service.js';
10
+ import { countDocumentsUser } from '../services/user.service.js';
11
+ import { countDocumentsTeams } from '../services/teams.service.js';
12
+ import { countDocumentsClusters } from '../services/cluster.service.js';
10
13
 
11
14
 
12
15
  export async function infraCard( req, res ) {
@@ -1878,3 +1881,30 @@ export async function checkPermission( req, res, next ) {
1878
1881
  res.sendError( 'Internal Server Error', 500 );
1879
1882
  }
1880
1883
  };
1884
+
1885
+ export async function getcount( req, res ) {
1886
+ try {
1887
+ let storecountQuery ={ 'clientId': { $in: req.body.clientId }, 'status': 'active' };
1888
+
1889
+ if ( req.user&&req.user.userType ==='client'&&req.user.role!='superadmin' ) {
1890
+ storecountQuery = { ...storecountQuery, ...{ storeId: { $in: req.body.assignedStores } } };
1891
+ }
1892
+
1893
+ let storeCount = await countDocumentsStore( storecountQuery );
1894
+ let userCount = await countDocumentsUser( { 'clientId': { $in: req.body.clientId }, 'isActive': true } );
1895
+ let teamCount = await countDocumentsTeams( { 'clientId': { $in: req.body.clientId } } );
1896
+ let clusterCount = await countDocumentsClusters( { 'clientId': { $in: req.body.clientId } } );
1897
+
1898
+
1899
+ res.sendSuccess( {
1900
+ storeCount: storeCount,
1901
+ userCount: userCount,
1902
+ teamCount: teamCount,
1903
+ clusterCount: clusterCount,
1904
+ } );
1905
+ } catch ( error ) {
1906
+ logger.error( { error: error, function: 'getcount' } );
1907
+ res.sendError( 'Internal Server Error', 500 );
1908
+ }
1909
+ }
1910
+
@@ -69,6 +69,8 @@ export async function createTicket( req, res ) {
69
69
  if ( req.body.issueType === 'highcount' ) {
70
70
  param.Bucket = JSON.parse( process.env.BUCKET ).edgeAppSource;
71
71
 
72
+ param.file_path = `${req.body.storeId}/${dayjs( new Date( req.body.Date ) ).format( 'DD-MM-YYYY' )}/`;
73
+
72
74
  const edgeAppSource = await listFileByPath( param );
73
75
 
74
76
  if ( !auditOutputData?.data?.length && !edgeAppSource?.data?.length ) {
@@ -1,7 +1,7 @@
1
1
 
2
2
  import express from 'express';
3
3
  import { isAllowedSessionHandler, getAssinedStore } from 'tango-app-api-middleware';
4
- import { infraCard, installationCard, InstallationIssuesTable, infraIssuesTable, hourWiseDownClients, hourWiseDownstores, ticketCountSplit, overViewTable, ticketCount } from '../controllers/clientInfra.controller.js';
4
+ import { infraCard, installationCard, InstallationIssuesTable, infraIssuesTable, hourWiseDownClients, hourWiseDownstores, ticketCountSplit, overViewTable, ticketCount, getcount } from '../controllers/clientInfra.controller.js';
5
5
 
6
6
  export const clientInfraRouter = express.Router();
7
7
 
@@ -15,3 +15,5 @@ clientInfraRouter.post( '/hourWiseDownstores', isAllowedSessionHandler, getAssin
15
15
  clientInfraRouter.post( '/ticket-count', isAllowedSessionHandler, getAssinedStore, ticketCount );
16
16
  clientInfraRouter.post( '/ticket-count-split', isAllowedSessionHandler, getAssinedStore, ticketCountSplit );
17
17
  clientInfraRouter.post( '/overview-table', isAllowedSessionHandler, getAssinedStore, overViewTable );
18
+ clientInfraRouter.post( '/getcount', isAllowedSessionHandler, getAssinedStore, getcount );
19
+
@@ -11,3 +11,6 @@ export async function aggregateUser( query ) {
11
11
  export async function updateOneUser( query, data ) {
12
12
  return await dataModel.userModel.updateOne( query, { $set: data } );
13
13
  }
14
+ export async function countDocumentsUser( query ) {
15
+ return await dataModel.userModel.countDocuments( query );
16
+ }