tango-app-api-infra 3.3.3-beta.7 → 3.3.3-beta.8
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
|
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
|
|
97
|
-
|
|
98
|
-
|
|
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
|
|
122
|
+
const footfallData = getFootfall?.body?.hits?.hits?.[0]?._source;
|
|
103
123
|
|
|
104
|
-
if (
|
|
105
|
-
req.body.dataMismatch['reportedFootfall'] =
|
|
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 = {};
|