tango-app-api-infra 3.7.1-beta.8 → 3.7.1-beta.9

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.7.1-beta.8",
3
+ "version": "3.7.1-beta.9",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,5 +1,5 @@
1
1
  import { download, logger } from 'tango-app-api-middleware';
2
- import { bulkUpdate, getOpenSearchCount, getOpenSearchData, insertWithId } from 'tango-app-api-middleware/src/utils/openSearch.js';
2
+ import { bulkUpdate, getOpenSearchCount, getOpenSearchData, insertWithId, updateOpenSearchData } from 'tango-app-api-middleware/src/utils/openSearch.js';
3
3
  import { findOneStore } from '../services/store.service.js';
4
4
  // import { updateOneCamera } from '../services/camera.service.js';
5
5
  import dayjs from 'dayjs';
@@ -386,3 +386,16 @@ export async function getTickets( req, res ) {
386
386
  }
387
387
  }
388
388
 
389
+ export async function updateStatus( req, res ) {
390
+ try {
391
+ // const inputData = req.body;
392
+ const id = req.query;
393
+ await updateOpenSearchData( openSearch.footfallDirectory, id, { _doc: { status: 'closed' } } );
394
+ return res.sendSuccess( 'ticket closed successfully' );
395
+ } catch ( error ) {
396
+ const err = error.messgae || 'Internal Server Error';
397
+ logger.error( { error: error, data: req.body, function: 'infra-footfallDirectory-updateStatus' } );
398
+ return res.sendError( err, 500 );
399
+ }
400
+ }
401
+
@@ -12,6 +12,6 @@ footfallDirectoryRouter.get( '/ticket-summary', isAllowedSessionHandler, bulkVal
12
12
  footfallDirectoryRouter.get( '/ticket-list', isAllowedSessionHandler, bulkValidate( ticketListValid ), ticketList );
13
13
  footfallDirectoryRouter.get( '/get-tickets', isAllowedSessionHandler, bulkValidate( getTicketsValid ), getTickets );
14
14
 
15
- // footfallDirectoryRouter.put( '/update-status', bulkValidate( updateStatus ), getTickets );
15
+ // footfallDirectoryRouter.put( '/update-status', bulkValidate( updateStatusValid ), updateStatus );
16
16
 
17
17
  // footfallDirectoryRouter.get( '/ticket-list', ticketList );
@@ -5,33 +5,27 @@ export async function isExist( req, res, next ) {
5
5
  const inputData=req.body;
6
6
  const opensearch = JSON.parse( process.env.OPENSEARCH );
7
7
  const query = {
8
- 'query': {
9
- 'bool': {
8
+ query: {
9
+ bool: {
10
10
  must: [
11
11
  {
12
- 'term': {
12
+ term: {
13
13
  'storeId.keyword': inputData?.storeId,
14
14
  },
15
15
  },
16
-
17
16
  {
18
- 'term': {
17
+ term: {
19
18
  'dateString.keyword': inputData?.dateString,
20
19
  },
21
20
  },
22
- {
23
- 'term': {
24
- 'ticketName.keyword': inputData?.ticketName,
25
- },
26
- },
27
21
  ],
28
22
  },
29
23
  },
30
-
31
24
  };
32
25
 
33
26
  const getData = await getOpenSearchCount( opensearch.footfallDirectory, query );
34
27
  const isExist = getData?.body?.count == 0? true : false;
28
+ logger.info( { isExist: isExist, count: getData?.body } );
35
29
  if ( isExist === true ) {
36
30
  next();
37
31
  } else {