tango-app-api-infra 3.3.3-beta.0 → 3.3.3-beta.10

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/README.md CHANGED
@@ -1,29 +1,29 @@
1
- # README #
2
-
3
- This README would normally document whatever steps are necessary to get your application up and running.
4
-
5
- ### What is this repository for? ###
6
-
7
- * Quick summary
8
- * Version
9
- * [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
10
-
11
- ### How do I get set up? ###
12
-
13
- * Summary of set up
14
- * Configuration
15
- * Dependencies
16
- * Database configuration
17
- * How to run tests
18
- * Deployment instructions
19
-
20
- ### Contribution guidelines ###
21
-
22
- * Writing tests
23
- * Code review
24
- * Other guidelines
25
-
26
- ### Who do I talk to? ###
27
-
28
- * Repo owner or admin
1
+ # README #
2
+
3
+ This README would normally document whatever steps are necessary to get your application up and running.
4
+
5
+ ### What is this repository for? ###
6
+
7
+ * Quick summary
8
+ * Version
9
+ * [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
10
+
11
+ ### How do I get set up? ###
12
+
13
+ * Summary of set up
14
+ * Configuration
15
+ * Dependencies
16
+ * Database configuration
17
+ * How to run tests
18
+ * Deployment instructions
19
+
20
+ ### Contribution guidelines ###
21
+
22
+ * Writing tests
23
+ * Code review
24
+ * Other guidelines
25
+
26
+ ### Who do I talk to? ###
27
+
28
+ * Repo owner or admin
29
29
  * Other community or team contact
package/package.json CHANGED
@@ -1,43 +1,43 @@
1
- {
2
- "name": "tango-app-api-infra",
3
- "version": "3.3.3-beta.0",
4
- "description": "infra",
5
- "main": "index.js",
6
- "type": "module",
7
- "scripts": {
8
- "start": "nodemon --exec \"eslint --fix . && node index.js\""
9
- },
10
- "engines": {
11
- "node": ">=18.10.0"
12
- },
13
- "author": "praveenraj",
14
- "license": "ISC",
15
- "dependencies": {
16
- "aws-sdk": "^2.1571.0",
17
- "cors": "^2.8.5",
18
- "dayjs": "^1.11.13",
19
- "dayjs-plugin-utc": "^0.1.2",
20
- "dotenv": "^16.4.5",
21
- "excel4node": "^1.8.2",
22
- "express": "^4.18.3",
23
- "express-fileupload": "^1.5.0",
24
- "handlebars": "^4.7.8",
25
- "html-pdf-node": "^1.0.8",
26
- "joi-to-swagger": "^6.2.0",
27
- "mongodb": "^6.4.0",
28
- "nodemon": "^3.1.0",
29
- "swagger-ui-express": "^5.0.0",
30
- "tango-api-schema": "^2.2.29",
31
- "tango-app-api-middleware": "^3.1.50",
32
- "winston": "^3.12.0",
33
- "winston-daily-rotate-file": "^5.0.0"
34
- },
35
- "devDependencies": {
36
- "eslint": "^8.57.0",
37
- "eslint-config-google": "^0.14.0",
38
- "eslint-config-semistandard": "^17.0.0",
39
- "eslint-config-standard": "^17.1.0",
40
- "eslint-plugin-import": "^2.29.1",
41
- "eslint-plugin-promise": "^6.1.1"
42
- }
43
- }
1
+ {
2
+ "name": "tango-app-api-infra",
3
+ "version": "3.3.3-beta.10",
4
+ "description": "infra",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "start": "nodemon --exec \"eslint --fix . && node index.js\""
9
+ },
10
+ "engines": {
11
+ "node": ">=18.10.0"
12
+ },
13
+ "author": "praveenraj",
14
+ "license": "ISC",
15
+ "dependencies": {
16
+ "aws-sdk": "^2.1571.0",
17
+ "cors": "^2.8.5",
18
+ "dayjs": "^1.11.13",
19
+ "dayjs-plugin-utc": "^0.1.2",
20
+ "dotenv": "^16.4.5",
21
+ "excel4node": "^1.8.2",
22
+ "express": "^4.18.3",
23
+ "express-fileupload": "^1.5.0",
24
+ "handlebars": "^4.7.8",
25
+ "html-pdf-node": "^1.0.8",
26
+ "joi-to-swagger": "^6.2.0",
27
+ "mongodb": "^6.4.0",
28
+ "nodemon": "^3.1.0",
29
+ "swagger-ui-express": "^5.0.0",
30
+ "tango-api-schema": "^2.2.29",
31
+ "tango-app-api-middleware": "^3.1.78",
32
+ "winston": "^3.12.0",
33
+ "winston-daily-rotate-file": "^5.0.0"
34
+ },
35
+ "devDependencies": {
36
+ "eslint": "^8.57.0",
37
+ "eslint-config-google": "^0.14.0",
38
+ "eslint-config-semistandard": "^17.0.0",
39
+ "eslint-config-standard": "^17.1.0",
40
+ "eslint-plugin-import": "^2.29.1",
41
+ "eslint-plugin-promise": "^6.1.1"
42
+ }
43
+ }
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { findOneTangoTicket, createTangoTicket, updateOneTangoTicket, aggregateTangoTicket, countDocumentsTangoTicket, findTangoTicket } from '../services/tangoTicket.service.js';
3
- import { logger, getUTC, fileUpload, signedUrl, sendMessageToQueue, listFileByPath } from 'tango-app-api-middleware';
3
+ import { logger, getUTC, fileUpload, signedUrl, sendMessageToQueue, listFileByPath, getOpenSearchData } from 'tango-app-api-middleware';
4
4
  import dayjs from 'dayjs';
5
5
  import { findlowcountReason } from '../services/lowcountReason.service.js';
6
6
 
@@ -93,16 +93,38 @@ export async function createTicket( req, res ) {
93
93
  processType: ( auditInputData?.data?.length && auditOutputData?.data?.length ) ? 'audit' : 'reduction',
94
94
  };
95
95
 
96
- const reqData = {
97
- 'dateString': dayjs( new Date( req.body.Date ) ).format( 'YYYY-MM-DD' ),
98
- 'storeId': req.body.storeId,
99
- };
100
-
96
+ const getFootfall = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).auditData,
97
+ {
98
+ 'query': {
99
+ 'bool': {
100
+ 'must': [
101
+ {
102
+ 'match': {
103
+ 'date_string': {
104
+ 'query': dayjs( req.body.Date ).format( 'YYYY-MM-DD' ),
105
+ 'operator': 'and',
106
+ },
107
+ },
108
+ },
109
+ {
110
+ 'match': {
111
+ 'store_id': {
112
+ 'query': req.body.storeId,
113
+ 'operator': 'and',
114
+ },
115
+ },
116
+ },
117
+ ],
118
+ },
119
+ },
120
+ } );
101
121
 
102
- const getFootfall = await postApi( `${JSON.parse( process.env.URL ).oldapidomain}/getFootfall`, reqData );
122
+ const footfallData = getFootfall?.body?.hits?.hits?.[0]?._source;
103
123
 
104
- if ( getFootfall?.data?.length ) {
105
- req.body.dataMismatch['reportedFootfall'] = getFootfall.data[0].footfall_count;
124
+ if ( footfallData ) {
125
+ req.body.dataMismatch['reportedFootfall'] = footfallData?.footfall_count;
126
+ } else {
127
+ req.body.dataMismatch['reportedFootfall'] = null;
106
128
  }
107
129
 
108
130
  req.body.issueDate = new Date( req.body.Date );
@@ -149,30 +171,12 @@ export async function createTicket( req, res ) {
149
171
  res.sendSuccess( 'Ticket Created Successfully' );
150
172
  }
151
173
  } catch ( error ) {
174
+ console.log( error );
152
175
  logger.error( { error: error, function: 'createTicket Data Mismatch' } );
153
176
  return res.sendError( error, 500 );
154
177
  }
155
178
  }
156
179
 
157
- async function postApi( url, data ) {
158
- const requestOptions = {
159
- method: 'POST',
160
- headers: {
161
- 'Content-Type': 'application/json',
162
- 'Authorization': 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66',
163
- },
164
- body: JSON.stringify( data ),
165
- };
166
-
167
- try {
168
- const response = await fetch( url, requestOptions );
169
- const data = await response.json();
170
- return data;
171
- } catch ( error ) {
172
- logger.error( { error: error, message: data, function: 'postApi' } );
173
- }
174
- }
175
-
176
180
  export async function updateMat( req, res ) {
177
181
  try {
178
182
  let updateValue = {};