tango-app-api-trax 3.7.2-multireff-12 → 3.7.2-multireff-14

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/app.js ADDED
@@ -0,0 +1,55 @@
1
+
2
+ import express from 'express';
3
+ import { traxRouter, mobileRouter, traxFlagRouter, traxDashboardRouter, galleryRouter, internalTraxRouter, downloadRouter } from './index.js';
4
+ import responseMiddleware from './config/response/response.js';
5
+ import errorMiddleware from './config/response/response.js';
6
+ import dotenv from 'dotenv';
7
+ import { logger } from 'tango-app-api-middleware';
8
+ import { connectdb } from './config/database/database.js';
9
+ import cors from 'cors';
10
+ import pkg from 'body-parser';
11
+ import fileupload from 'express-fileupload';
12
+ import admin from 'firebase-admin';
13
+ const serviceAccountPath = JSON.parse( process.env.FIREBASE );
14
+ admin.initializeApp( {
15
+ credential: admin.credential.cert( serviceAccountPath ),
16
+ } );
17
+ const env=dotenv.config();
18
+
19
+
20
+ const app = express();
21
+ const PORT = process.env.PORT || 3000;
22
+ const { json, urlencoded } =pkg;
23
+
24
+
25
+ if ( env.error ) {
26
+ logger.error( '.env not found' );
27
+ process.exit( 1 );
28
+ }
29
+
30
+ app.use( cors() );
31
+ app.use( responseMiddleware );
32
+ app.use( errorMiddleware );
33
+ app.use( json( { limit: '500mb' } ) );
34
+ app.use( fileupload() );
35
+ app.use(
36
+ urlencoded( {
37
+ extended: true,
38
+ } ),
39
+ );
40
+
41
+ app.use( '/trax', traxRouter );
42
+ app.use( '/trax/flag', traxFlagRouter );
43
+ app.use( '/trax/mobileAPI', mobileRouter );
44
+ app.use( '/trax/dashboard', traxDashboardRouter );
45
+ app.use( '/gallery', galleryRouter );
46
+ app.use( '/trax/internalAPI', internalTraxRouter );
47
+ app.use( '/trax/downloads', downloadRouter );
48
+
49
+ const host = '0.0.0.0';
50
+
51
+ app.listen( PORT, host, () => {
52
+ logger.info( `server is running on port= ${PORT} ` );
53
+ connectdb();
54
+ } );
55
+
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "tango-app-api-trax",
3
- "version": "3.7.2-multireff-12",
3
+ "version": "3.7.2-multireff-14",
4
4
  "description": "Trax",
5
- "main": "index.js",
5
+ "main": "app.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
- "start": "nodemon --exec \"eslint --fix . && node index.js\""
8
+ "start": "nodemon --exec \"eslint --fix . && node app.js\""
9
9
  },
10
10
  "engines": {
11
11
  "node": ">=18.10.0"
@@ -27,7 +27,7 @@
27
27
  "mongodb": "^6.8.0",
28
28
  "nodemon": "^3.1.4",
29
29
  "path": "^0.12.7",
30
- "tango-api-schema": "^2.2.198",
30
+ "tango-api-schema": "^2.3.19",
31
31
  "tango-app-api-middleware": "^3.1.77",
32
32
  "url": "^0.11.4",
33
33
  "winston": "^3.13.1",
@@ -2022,7 +2022,7 @@ export async function submitTask( req, res ) {
2022
2022
  const updateQuery = {
2023
2023
  _id: new ObjectId( processedcheckListId ),
2024
2024
  userId: user._id,
2025
- date_string: date,
2025
+ // date_string: date,
2026
2026
  };
2027
2027
 
2028
2028
  // questionAnswers.forEach( ( section ) => {
@@ -2928,7 +2928,7 @@ export async function checklistv1( req, res ) {
2928
2928
 
2929
2929
  const [ checklistResult, taskResult ] = await Promise.allSettled( [
2930
2930
  processedchecklist.aggregate( buildPipeline( [ { checkListType: 'custom' } ], { isPlano: 1, planoId: 1, planoType: 1, floorId: 1 } ) ),
2931
- processedTask.aggregate( taskBuildPipeline( [], { isPlano: 1, planoId: 1, planoType: 1, floorId: 1 } ) ),
2931
+ processedTask.aggregate( taskBuildPipeline( [], { isPlano: 1, planoId: 1, planoType: 1, floorId: 1, refTaskId: 1 } ) ),
2932
2932
  ] );
2933
2933
 
2934
2934
  const checklistData = checklistResult.status === 'fulfilled' ? checklistResult.value : [];
@@ -3006,7 +3006,9 @@ export const flagTablesV2 = async ( req, res ) => {
3006
3006
  } else if ( requestData?.filter === 'detection' ) {
3007
3007
  findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum' ] } } );
3008
3008
  } else if ( requestData?.filter === 'runAI' ) {
3009
- findAndQuery.push( { checkListName: { $in: req.body.runAIChecklistName } } );
3009
+ if ( req.body.runAIChecklistName ) {
3010
+ findAndQuery.push( { checkListName: { $in: req.body.runAIChecklistName } } );
3011
+ }
3010
3012
  }
3011
3013
 
3012
3014
  findQuery.push( { $match: { $and: findAndQuery } } );
@@ -3186,7 +3188,7 @@ export const flagTablesV2 = async ( req, res ) => {
3186
3188
  getChecklistPerformanceData[index].flaggedStores = getChecklistPerformanceData[index].flaggedStores + findCheckList.flagCount;
3187
3189
  } else {
3188
3190
  getChecklistPerformanceData[index].flagCount = findCheckList.flagCount;
3189
- getChecklistPerformanceData[index].flaggedStores = findCheckList.flagCount;
3191
+ getChecklistPerformanceData[index].flaggedStores = findCheckList.flagStoreCount;
3190
3192
  }
3191
3193
  } else {
3192
3194
  if ( requestData?.filter == 'all' ) {
@@ -3222,22 +3224,28 @@ export const flagTablesV2 = async ( req, res ) => {
3222
3224
  const data = {
3223
3225
  'Checklist Name': element.checkListName,
3224
3226
  'Coverage': element?.coverage,
3227
+ 'No of Questions': element?.runAIQuestionCount,
3225
3228
  'Assigned Stores': element?.checkListType === 'custom' ? element?.assignedStores : element?.assignedStoresAi,
3226
3229
  'Flagged Stores': element?.flaggedStores,
3227
3230
  'Question Flags': element?.customQuestionFlagCount,
3228
3231
  ...( element.runAIFlag ? { 'Run AI Flag': element.runAIFlag } : {} ),
3229
3232
  'Not Submitted Flags': element?.customTimeFlagCount,
3230
3233
  'Detection Flags': element?.flagCount,
3234
+ 'Flags': element?.flagCount,
3231
3235
  'Compliance': element?.complianceRate,
3232
3236
  // 'Flag Type': element?.checkListType === 'custom' ? 'Question' : 'Detection',
3233
3237
  };
3234
- if ( requestData?.filter === 'question' ) {
3238
+ if ( requestData?.filter === 'all' ) {
3239
+ delete data['No of Questions'];
3240
+ delete data['Flags'];
3241
+ } else if ( requestData?.filter === 'question' ) {
3235
3242
  data['Flags'] = data['Question Flags'];
3236
3243
  delete data['Question Flags'];
3237
3244
  delete data['Flagged Count'];
3238
3245
  delete data['Not Submitted Flags'];
3239
3246
  delete data['Detection Flags'];
3240
3247
  delete data['Run AI Flag'];
3248
+ delete data['No of Questions'];
3241
3249
  } else if ( requestData?.filter === 'time' ) {
3242
3250
  data['Flags'] = data['Not Submitted Flags'];
3243
3251
  delete data['Question Flags'];
@@ -3245,7 +3253,16 @@ export const flagTablesV2 = async ( req, res ) => {
3245
3253
  delete data['Not Submitted Flags'];
3246
3254
  delete data['Detection Flags'];
3247
3255
  delete data['Run AI Flag'];
3256
+ delete data['No of Questions'];
3248
3257
  } else if ( requestData?.filter === 'detection' ) {
3258
+ data['Flags'] = data['Detection Flags'];
3259
+ delete data['Question Flags'];
3260
+ delete data['Flagged Count'];
3261
+ delete data['Not Submitted Flags'];
3262
+ delete data['Run AI Flag'];
3263
+ delete data['Flags'];
3264
+ delete data['No of Questions'];
3265
+ } else if ( requestData?.filter === 'runAI' ) {
3249
3266
  data['Flags'] = data['Detection Flags'];
3250
3267
  delete data['Question Flags'];
3251
3268
  delete data['Flagged Count'];