tango-app-api-infra 3.3.3-beta.4 → 3.3.3-beta.6

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.3.3-beta.4",
3
+ "version": "3.3.3-beta.6",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1038,9 +1038,24 @@ export async function saveInfraEmailConfig( req, res ) {
1038
1038
  try {
1039
1039
  let inputData = req.body;
1040
1040
  let client = await findOneClient( { clientId: inputData.clientId } );
1041
+ let intervaltimenew='';
1042
+ let intervaltimeold='';
1043
+ if ( inputData.configuration.type ==='customize' ) {
1044
+ intervaltimeold= `Starts at ${client.ticketConfigs.infraReport.startTime}, repeats every ${client.ticketConfigs.infraReport.interval} minutes, and ends at ${client.ticketConfigs.infraReport.endTime}`;
1045
+ let oldtime=inputData.configuration.times.map( ( data ) => data.interval );
1046
+ oldtime = Array.isArray( oldtime ) ? [ ...new Set( oldtime ) ].join( ', ' ) : '';
1047
+ intervaltimenew = `occurs at ${oldtime}`; ;
1048
+ } else {
1049
+ let oldtime=client.ticketConfigs.infraReport.times.map( ( data ) => data.interval );
1050
+ oldtime = Array.isArray( oldtime ) ? [ ...new Set( oldtime ) ].join( ', ' ) : '';
1051
+ intervaltimeold=`occurs at ${oldtime}`;
1052
+ intervaltimenew=`Starts at ${inputData.configuration.startTime}, repeats every ${inputData.configuration.interval} minutes, and ends at ${inputData.configuration.endTime}`;
1053
+ }
1041
1054
  await updateoneClient( { clientId: inputData.clientId }, {
1042
1055
  'ticketConfigs.infraReport': inputData.configuration,
1043
1056
  } );
1057
+
1058
+
1044
1059
  if ( inputData.type === 'users' ) {
1045
1060
  if ( inputData.userList && inputData.userList.length > 0 ) {
1046
1061
  for ( let user of inputData.userList ) {
@@ -1064,6 +1079,16 @@ export async function saveInfraEmailConfig( req, res ) {
1064
1079
  }
1065
1080
 
1066
1081
 
1082
+ let oldData={
1083
+ alertsType: `${client.ticketConfigs.infraReport.type} Interval`,
1084
+ intervalTime: intervaltimeold,
1085
+ };
1086
+ let newData={
1087
+ alertsType: `${inputData.configuration.type} Interval`,
1088
+ intervalTime: intervaltimenew,
1089
+
1090
+ };
1091
+
1067
1092
  const logObj = {
1068
1093
  clientId: inputData.clientId,
1069
1094
  userName: req.user?.userName,
@@ -1074,14 +1099,12 @@ export async function saveInfraEmailConfig( req, res ) {
1074
1099
  eventType: 'update',
1075
1100
  showTo: [ 'tango' ],
1076
1101
  changes: [ `Email Config` ],
1077
- previous: client.ticketConfigs.infraReport,
1078
- current: {
1079
- infraReport: {
1080
- start: inputData.start,
1081
- end: inputData.end,
1082
- },
1083
- },
1102
+ oldData: oldData,
1103
+ newData: newData,
1104
+ previous: oldData,
1105
+ current: newData,
1084
1106
  };
1107
+ console.log( logObj );
1085
1108
 
1086
1109
  await insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
1087
1110
 
@@ -1857,7 +1880,7 @@ export async function infraTable( req, res ) {
1857
1880
  'Brand ID': element.clientId,
1858
1881
  'Store Name': element.storeName,
1859
1882
  'Store ID': element.storeId,
1860
- 'Resloved By': element.userName,
1883
+ 'Resolved By': element.userName,
1861
1884
  'Status': element.status,
1862
1885
  'Primary Issues': element.primaryIssue == '-' ? 'Issue not identified' : element.primaryIssue,
1863
1886
  'Secondary Issues': element.secondaryIssue,
@@ -2339,7 +2362,7 @@ export async function matTable( req, res ) {
2339
2362
  'Brand ID': element.clientId,
2340
2363
  'Store Name': element.storeName,
2341
2364
  'Store ID': element.storeId,
2342
- 'Resloved By': element.userName,
2365
+ 'Resolved By': element.userName,
2343
2366
  'Status': element.status,
2344
2367
  } );
2345
2368
  } );
@@ -2688,7 +2711,7 @@ export async function dataMismatchTable( req, res ) {
2688
2711
  'Brand ID': chunk[i]?.clientId,
2689
2712
  'Store Name': chunk[i]?.storeName,
2690
2713
  'Store ID': chunk[i]?.storeId,
2691
- 'Resloved By': chunk[i]?.userName,
2714
+ 'Resolved By': chunk[i]?.userName,
2692
2715
  'Issue Type': chunk[i]?.issueType,
2693
2716
  'Query Type ': chunk[i]?.type,
2694
2717
  'Status': chunk[i]?.status,
@@ -1033,7 +1033,7 @@ export async function infraReportSent( req, res ) {
1033
1033
  const fileContent = readFileSync( join() + '/src/hbs/dailyInfraReport.hbs', 'utf8' );
1034
1034
  const htmlContent = handlebars.compile( fileContent );
1035
1035
  let Uidomain = `${JSON.parse( process.env.URL ).domain}`;
1036
- const html = htmlContent( { ...req.body, Uidomain: Uidomain, issueCount: issueCount, avgDownTime: avgDownTime, reportdate:dayjs(date).format( 'DD-MM-YYYY' ), content: obj, date: date, csmEmail: csmEmail, domain: JSON.parse( process.env.URL ).apiDomain } );
1036
+ const html = htmlContent( { ...req.body, Uidomain: Uidomain, issueCount: issueCount, avgDownTime: avgDownTime, reportdate: dayjs( date ).format( 'DD-MM-YYYY' ), content: obj, date: date, csmEmail: csmEmail, domain: JSON.parse( process.env.URL ).apiDomain } );
1037
1037
  if ( isValidEmail( req.body.email ) ) {
1038
1038
  const result = await sendEmailWithSES( req.body.email, subject, html, attachments, JSON.parse( process.env.SES ).adminEmail );
1039
1039
  res.sendSuccess( result );
@@ -160,7 +160,7 @@ export async function storeTicketList( req, res ) {
160
160
  'STORE ID': element.storeId,
161
161
  'TICKET ID': element.ticketId,
162
162
  'DATE': dayjs( element.createdAt ).format( 'DD MMM, YYYY' ),
163
- 'ISSUE CLOSED DATE': element.issueClosedDate?dayjs( element.issueClosedDate ).format( 'DD MMM, YYYY' ):"",
163
+ 'ISSUE CLOSED DATE': element.issueClosedDate?dayjs( element.issueClosedDate ).format( 'DD MMM, YYYY' ):'',
164
164
  'PRIMARY ISSUE': element.primaryIssue,
165
165
  'SECONDARY ISSUE': element.secondaryIssue,
166
166
  'STATUS': element.status,
@@ -5,6 +5,10 @@ export async function findOneUser( query, project ) {
5
5
  return await dataModel.userModel.findOne( query, project );
6
6
  }
7
7
 
8
+ export async function findUser( query, project ) {
9
+ return await dataModel.userModel.find( query, project );
10
+ }
11
+
8
12
  export async function aggregateUser( query ) {
9
13
  return await dataModel.userModel.aggregate( query );
10
14
  }