tango-app-api-infra 3.0.56-dev → 3.0.58-dev

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.0.56-dev",
3
+ "version": "3.0.58-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,9 +1,9 @@
1
1
 
2
2
 
3
- import { aggregateTangoTicket, createTangoTicket, findOneTangoTicket, updateOneTangoTicket, updateManyTangoTicket } from '../services/tangoTicket.service.js';
3
+ import { aggregateTangoTicket, createTangoTicket, findOneTangoTicket, updateOneTangoTicket, updateManyTangoTicket, findTangoTicket } from '../services/tangoTicket.service.js';
4
4
  import { createinfraReason, findinfraReason } from '../services/infraReason.service.js';
5
5
  import { updateOneStore, findStore } from '../services/store.service.js';
6
- import { logger, fileUpload, signedUrl, sendEmailWithSES, getOpenSearchData, appConfig, getUTC } from 'tango-app-api-middleware';
6
+ import { logger, fileUpload, signedUrl, sendEmailWithSES, getOpenSearchData, download, appConfig, getUTC } from 'tango-app-api-middleware';
7
7
  import { aggregateUser, updateOneUser } from '../services/user.service.js';
8
8
  import { updateoneClient } from '../services/client.service.js';
9
9
  import dayjs from 'dayjs';
@@ -652,6 +652,7 @@ export async function infraTable( req, res ) {
652
652
  status: 1,
653
653
  createdAt: 1,
654
654
  issueDate: 1,
655
+ addressingUser: { $toObjectId: '$ticketDetails.addressingUser' },
655
656
  primaryIssue: {
656
657
  $filter: {
657
658
  input: '$ticketActivity',
@@ -683,6 +684,7 @@ export async function infraTable( req, res ) {
683
684
  storeName: 1,
684
685
  clientName: 1,
685
686
  createdAt: 1,
687
+ addressingUser: 1,
686
688
  ticketId: 1,
687
689
  issueDate: { $ifNull: [ '$issueDate', '' ] },
688
690
  status: 1,
@@ -690,6 +692,36 @@ export async function infraTable( req, res ) {
690
692
  secondaryIssue: { $ifNull: [ '$primaryIssue.reasons.secondaryIssue.name', '-' ] },
691
693
  },
692
694
  },
695
+ {
696
+ '$lookup': {
697
+ 'from': 'users',
698
+ 'let': { 'userId': '$addressingUser' },
699
+ 'pipeline': [
700
+ {
701
+ '$match': {
702
+ '$expr': {
703
+ '$eq': [ '$_id', '$$userId' ],
704
+ },
705
+ },
706
+ },
707
+ {
708
+ '$project': {
709
+ 'userName': 1,
710
+ 'email': 1,
711
+ 'role': 1,
712
+ },
713
+ },
714
+ ],
715
+ 'as': 'user',
716
+ },
717
+ },
718
+
719
+ {
720
+ $unwind: {
721
+ path: '$user',
722
+ preserveNullAndEmptyArrays: true,
723
+ },
724
+ },
693
725
  {
694
726
  $group: {
695
727
  _id: '$ticketId',
@@ -697,6 +729,8 @@ export async function infraTable( req, res ) {
697
729
  clientId: { $first: '$clientId' },
698
730
  ticketId: { $first: '$ticketId' },
699
731
  storeName: { $first: '$storeName' },
732
+ userName: { $first: { $ifNull: [ '$user.userName', '-' ] } },
733
+ userEmail: { $first: { $ifNull: [ '$user.email', '-' ] } },
700
734
  clientName: { $first: '$clientName' },
701
735
  createdAt: { $first: '$createdAt' },
702
736
  issueDate: { $last: '$issueDate' },
@@ -704,19 +738,34 @@ export async function infraTable( req, res ) {
704
738
  primaryIssue: { $last: '$primaryIssue' },
705
739
  secondaryIssue: { $last: '$secondaryIssue' },
706
740
  },
707
- } );
741
+ },
742
+ );
708
743
  if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
709
744
  query.push( {
710
745
  $sort: { [req.body.sortColumName]: req.body.sortBy },
711
746
  } );
712
747
  }
713
- if ( req.body.storeIdFilter && req.body.storeIdFilter.length>0 ) {
748
+ if ( req.body.storeIdFilter && req.body.storeIdFilter.length > 0 ) {
714
749
  query.push( {
715
750
  $match: {
716
751
  storeId: { $in: req.body.storeIdFilter },
717
752
  },
718
753
  } );
719
754
  }
755
+ if ( req.body.statusFilter && req.body.statusFilter.length > 0 ) {
756
+ query.push( {
757
+ $match: {
758
+ status: { $in: req.body.statusFilter },
759
+ },
760
+ } );
761
+ }
762
+ if ( req.body.userFilter && req.body.userFilter.length > 0 ) {
763
+ query.push( {
764
+ $match: {
765
+ userEmail: { $in: req.body.userFilter },
766
+ },
767
+ } );
768
+ }
720
769
  let ticketList = await aggregateTangoTicket( query );
721
770
  let issueList = await findinfraReason( { parentId: { '$exists': false } } );
722
771
  const categoryCounts = {};
@@ -776,7 +825,17 @@ export async function infraTable( req, res ) {
776
825
  const exportdata = [];
777
826
  result.forEach( ( element ) => {
778
827
  exportdata.push( {
779
-
828
+ 'ticketId': element.ticketId,
829
+ 'issueDate': dayjs( element.issueDate ).format( 'DD-MM-YYYY' ),
830
+ 'storeId': element.storeId,
831
+ 'storeName': element.storeName,
832
+ 'clientId': element.clientId,
833
+ 'clientName': element.clientName,
834
+ 'userName': element.userName,
835
+ 'userEmail': element.userEmail,
836
+ 'Status': element.status,
837
+ 'StatusDetails': element.primaryIssue,
838
+ 'SubIssue': element.secondaryIssue,
780
839
  } );
781
840
  } );
782
841
  await download( exportdata, res );
@@ -816,7 +875,8 @@ export async function installationTable( req, res ) {
816
875
  { createdAt: { $lte: date.end } },
817
876
  ],
818
877
  },
819
- }, {
878
+ },
879
+ {
820
880
  $project: {
821
881
  storeId: '$basicDetails.storeId',
822
882
  clientId: '$basicDetails.clientId',
@@ -825,6 +885,7 @@ export async function installationTable( req, res ) {
825
885
  clientName: '$basicDetails.clientName',
826
886
  status: 1,
827
887
  createdAt: 1,
888
+ addressingUser: '$ticketDetails.addressingUser',
828
889
  installationStatus: '$ticketDetails.installationStatus',
829
890
  issueDate: 1,
830
891
  primaryIssue: {
@@ -859,13 +920,44 @@ export async function installationTable( req, res ) {
859
920
  clientName: 1,
860
921
  createdAt: 1,
861
922
  ticketId: 1,
862
- installationStatus: 1,
923
+ addressingUser: 1,
924
+ installationStatus: { $ifNull: [ '$installationStatus', '-' ] },
863
925
  issueDate: { $ifNull: [ '$issueDate', '' ] },
864
926
  status: 1,
865
927
  primaryIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '-' ] },
866
928
  secondaryIssue: { $ifNull: [ '$primaryIssue.reasons.secondaryIssue.name', '-' ] },
867
929
  },
868
930
  },
931
+ {
932
+ '$lookup': {
933
+ 'from': 'users',
934
+ 'let': { 'userId': '$addressingUser' },
935
+ 'pipeline': [
936
+ {
937
+ '$match': {
938
+ '$expr': {
939
+ '$eq': [ '$_id', '$$userId' ],
940
+ },
941
+ },
942
+ },
943
+ {
944
+ '$project': {
945
+ 'userName': 1,
946
+ 'email': 1,
947
+ 'role': 1,
948
+ },
949
+ },
950
+ ],
951
+ 'as': 'user',
952
+ },
953
+ },
954
+
955
+ {
956
+ $unwind: {
957
+ path: '$user',
958
+ preserveNullAndEmptyArrays: true,
959
+ },
960
+ },
869
961
  {
870
962
  $group: {
871
963
  _id: '$ticketId',
@@ -873,6 +965,8 @@ export async function installationTable( req, res ) {
873
965
  clientId: { $first: '$clientId' },
874
966
  ticketId: { $first: '$ticketId' },
875
967
  storeName: { $first: '$storeName' },
968
+ userName: { $first: { $ifNull: [ '$user.userName', '-' ] } },
969
+ userEmail: { $first: { $ifNull: [ '$user.email', '-' ] } },
876
970
  clientName: { $first: '$clientName' },
877
971
  createdAt: { $first: '$createdAt' },
878
972
  issueDate: { $last: '$issueDate' },
@@ -881,12 +975,34 @@ export async function installationTable( req, res ) {
881
975
  primaryIssue: { $last: '$primaryIssue' },
882
976
  secondaryIssue: { $last: '$secondaryIssue' },
883
977
  },
884
- } );
978
+ },
979
+ );
885
980
  if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
886
981
  query.push( {
887
982
  $sort: { [req.body.sortColumName]: req.body.sortBy },
888
983
  } );
889
984
  }
985
+ if ( req.body.storeIdFilter && req.body.storeIdFilter.length > 0 ) {
986
+ query.push( {
987
+ $match: {
988
+ storeId: { $in: req.body.storeIdFilter },
989
+ },
990
+ } );
991
+ }
992
+ if ( req.body.statusFilter && req.body.statusFilter.length > 0 ) {
993
+ query.push( {
994
+ $match: {
995
+ installationStatus: { $in: req.body.statusFilter },
996
+ },
997
+ } );
998
+ }
999
+ if ( req.body.userFilter && req.body.userFilter.length > 0 ) {
1000
+ query.push( {
1001
+ $match: {
1002
+ userEmail: { $in: req.body.userFilter },
1003
+ },
1004
+ } );
1005
+ }
890
1006
  let ticketList = await aggregateTangoTicket( query );
891
1007
  let issueList = await findinfraReason( { parentId: { '$exists': false } } );
892
1008
  const categoryCounts = {};
@@ -933,7 +1049,6 @@ export async function installationTable( req, res ) {
933
1049
  } );
934
1050
  }
935
1051
  let count = await aggregateTangoTicket( query );
936
- console.log( count.length );
937
1052
  if ( req.body.limit && req.body.offset && !req.body.export ) {
938
1053
  query.push(
939
1054
  { $skip: ( req.body.offset - 1 ) * req.body.limit },
@@ -946,7 +1061,17 @@ export async function installationTable( req, res ) {
946
1061
  const exportdata = [];
947
1062
  result.forEach( ( element ) => {
948
1063
  exportdata.push( {
949
-
1064
+ 'ticketId': element.ticketId,
1065
+ 'issueDate': dayjs( element.issueDate ).format( 'DD-MM-YYYY' ),
1066
+ 'storeId': element.storeId,
1067
+ 'storeName': element.storeName,
1068
+ 'clientId': element.clientId,
1069
+ 'clientName': element.clientName,
1070
+ 'userName': element.userName,
1071
+ 'userEmail': element.userEmail,
1072
+ 'Status': element.installationStatus,
1073
+ 'StatusDetails': element.primaryIssue,
1074
+ 'SubIssue': element.secondaryIssue,
950
1075
  } );
951
1076
  } );
952
1077
  await download( exportdata, res );
@@ -977,3 +1102,20 @@ export async function assignTicket( req, res ) {
977
1102
  return res.sendError( error, 500 );
978
1103
  }
979
1104
  }
1105
+ export async function storeFilter( req, res ) {
1106
+ try {
1107
+ let stores = await findTangoTicket( { 'issueType': req.body.issueType, 'basicDetails.clientId': req.body.clientId, 'basicDetails.storeId': { $exists: true } }, { 'basicDetails.storeId': 1 } );
1108
+ const uniqueStoreIds = [ ...new Set( stores.map( ( store ) => store.basicDetails.storeId ) ) ];
1109
+ const uniqueStoreObjects = uniqueStoreIds.map( ( storeId ) => ( { 'storeId': storeId } ) );
1110
+
1111
+ if ( uniqueStoreObjects.length>0 ) {
1112
+ res.sendSuccess( { count: uniqueStoreObjects.length, data: uniqueStoreObjects } );
1113
+ } else {
1114
+ res.sendError( 'No data', 204 );
1115
+ }
1116
+ } catch ( error ) {
1117
+ // console.log( error );
1118
+ logger.error( { error: error, function: 'storeFilter' } );
1119
+ return res.sendError( error, 500 );
1120
+ }
1121
+ }
@@ -17,7 +17,7 @@ import { findOneGroup } from '../services/group.service.js';
17
17
  import { findinfraReason } from '../services/infraReason.service.js';
18
18
  import { findOneUser } from '../services/user.service.js';
19
19
  import xl from 'excel4node';
20
-
20
+ import { findOneinfraReason } from '../services/infraReason.service.js';
21
21
  export async function migrateClient() {
22
22
  try {
23
23
  let oldclient = [];
@@ -697,7 +697,7 @@ export async function camAngleChangeReport( req, res ) {
697
697
  content: buffer,
698
698
  contentType: 'application/xlsx', // e.g., 'application/pdf'
699
699
  };
700
- let subject =`Camera Angle Modified - ${formattedPreviousDay}`;
700
+ let subject = `Camera Angle Modified - ${formattedPreviousDay}`;
701
701
  let html = `<div>We wanted to inform you that the camera angle in your stores has been adjusted recently.</div>`;
702
702
  let result = await sendEmailWithSES( req.body.toMail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
703
703
  if ( result ) {
@@ -737,3 +737,329 @@ export async function download( data ) {
737
737
  }
738
738
  return await wb.writeToBuffer();
739
739
  }
740
+ export async function edgeApplogsCheck( req, res ) {
741
+ try {
742
+ let finalresult= [];
743
+ let ticketList = await findTangoTicket( { 'issueDate': new Date( req.body.issueDate ), 'status': { $ne: 'closed' }, 'ticketDetails.issueStatus': 'notidentified', 'issueType': 'infra' } );
744
+ for ( let ticket of ticketList ) {
745
+ req.body.date = dayjs( ticket.createdAt ).format( 'YYYY-MM-DD' );
746
+ let errorLog = {
747
+ 'size': 500,
748
+ 'query': {
749
+ 'bool': {
750
+ 'must': [
751
+ {
752
+ 'range': {
753
+ 'log_code': {
754
+ 'gte': 1000,
755
+ },
756
+ },
757
+ },
758
+ {
759
+ 'term': {
760
+ 'store_date.keyword': dayjs( ticket.createdAt ).format( 'DD-MM-YYYY' ),
761
+ },
762
+ },
763
+ {
764
+ 'term': {
765
+ 'storeId.keyword': ticket.basicDetails.storeId,
766
+ },
767
+ },
768
+
769
+ ],
770
+
771
+ },
772
+ },
773
+ 'sort': [
774
+ { 'timestamp': { 'order': 'desc' } },
775
+ ],
776
+ };
777
+ const errorLogList = await getOpenSearchData( 'edgeapp_systemlogs', errorLog );
778
+
779
+ let result = [];
780
+
781
+ for ( let error of errorLogList.body.hits.hits ) {
782
+ if ( error._source.log_code == '1003' ) {
783
+ let logCheck = {
784
+ code: error._source.log_code,
785
+ edgelog: error._source.data,
786
+ };
787
+ result.push( logCheck );
788
+ }
789
+ // if ( error._source.log_code == '1001' ) {
790
+ // let logCheck = {
791
+ // code: error._source.log_code,
792
+ // edgelog: error._source.data,
793
+ // };
794
+ // result.push( logCheck );
795
+ // }
796
+
797
+ // if ( error._source.log_code == '1004' ) {
798
+ // let logCheck = {
799
+ // code: error._source.log_code,
800
+ // edgelog: error._source.data,
801
+
802
+ // };
803
+ // result.push( logCheck );
804
+ // }
805
+ if ( error._source.log_code == '1005' ) {
806
+ const bytes = error._source.data.upload_Speed.split( '.' )[0];
807
+ const megabytes = bytesToMB( bytes );
808
+ if ( megabytes < 2 ) {
809
+ let logCheck = {
810
+ code: error._source.log_code,
811
+ edgelog: error._source.data,
812
+
813
+ };
814
+ result.push( logCheck );
815
+ }
816
+ }
817
+
818
+
819
+ if ( error._source.log_code == '1011' ) {
820
+ let logCheck = {
821
+ code: error._source.log_code,
822
+ edgelog: error._source.data,
823
+
824
+ };
825
+ result.push( logCheck );
826
+ }
827
+ if ( error._source.log_code == '1022' ) {
828
+ let logCheck = {
829
+ code: error._source.log_code,
830
+ edgelog: error._source.data,
831
+
832
+ };
833
+ result.push( logCheck );
834
+ }
835
+ if ( error._source.log_code == '1024' ) {
836
+ let logCheck = {
837
+ code: error._source.log_code,
838
+ edgelog: error._source.data,
839
+
840
+ };
841
+ result.push( logCheck );
842
+ }
843
+ if ( error._source.log_code == '1025' ) {
844
+ let logCheck = {
845
+ code: error._source.log_code,
846
+ edgelog: error._source.data,
847
+
848
+ };
849
+ result.push( logCheck );
850
+ }
851
+
852
+ if ( error._source.log_code == '1000' ) {
853
+ let logCheck = {
854
+ code: error._source.log_code,
855
+ edgelog: error._source.data,
856
+
857
+ };
858
+ result.push( logCheck );
859
+ }
860
+
861
+ if ( error._source.log_code == '1007' ) {
862
+ let logCheck = {
863
+ code: error._source.log_code,
864
+ edgelog: error._source.data,
865
+
866
+ };
867
+ result.push( logCheck );
868
+ }
869
+ if ( error._source.log_code == '1034' ) {
870
+ let logCheck = {
871
+ code: error._source.log_code,
872
+ edgelog: error._source.data,
873
+
874
+ };
875
+ result.push( logCheck );
876
+ }
877
+
878
+ if ( Number( error._source.log_code ) > 2000 ) {
879
+ let logCheck = {
880
+ code: error._source.log_code,
881
+ edgelog: error._source.data,
882
+ };
883
+ result.push( logCheck );
884
+ }
885
+ }
886
+ let findissueEdgeApp = {};
887
+ if ( result.length>0 ) {
888
+ for ( let findissue of result ) {
889
+ // console.log( ticket.ticketId );
890
+ const istTimestamp = dayjs.utc( ticket.createdAt ).tz( 'Asia/Kolkata' ).format( 'HH:mm:ss' );
891
+
892
+ if ( findissue.code == '1003' ) {
893
+ // Compare the times
894
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
895
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
896
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
897
+ if ( isOccurringTimeEarlier ) {
898
+ findissueEdgeApp = {
899
+ ticketId: ticket.ticketId,
900
+ edgelog: findissue,
901
+ storeId: ticket.basicDetails.storeId,
902
+ primary: 'System Issues',
903
+ secondary: [ 'Malware or Viruses' ],
904
+ };
905
+ updateIssue( findissueEdgeApp );
906
+ finalresult.push( findissueEdgeApp );
907
+ // console.log( findissueEdgeApp );
908
+ }
909
+ } else if ( findissue.code == '1024' ) {
910
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.data.occuringTime}` );
911
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
912
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
913
+
914
+ const existsInArray = finalresult.some( ( item ) =>
915
+ item.ticketId === ticket.ticketId,
916
+ );
917
+ if ( isOccurringTimeEarlier&&!existsInArray ) {
918
+ findissueEdgeApp = {
919
+ ticketId: ticket.ticketId,
920
+ storeId: ticket.basicDetails.storeId,
921
+ edgelog: findissue.edgelog.data,
922
+ primary: 'Camera Issues',
923
+ secondary: [ 'Camera Not working/RTSP port not working' ],
924
+ };
925
+ updateIssue( findissueEdgeApp );
926
+ finalresult.push( findissueEdgeApp );
927
+ }
928
+ } else if ( findissue.code == '1011' ) {
929
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
930
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
931
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
932
+
933
+ if ( isOccurringTimeEarlier ) {
934
+ findissueEdgeApp = {
935
+ ticketId: ticket.ticketId,
936
+ edgelog: findissue,
937
+ storeId: ticket.basicDetails.storeId,
938
+ primary: 'System Issues',
939
+ secondary: [ 'System is in Sleep Mode' ],
940
+ };
941
+ updateIssue( findissueEdgeApp );
942
+ finalresult.push( findissueEdgeApp );
943
+ // console.log( findissueEdgeApp );
944
+ }
945
+ } else if ( findissue.code ==='1005' ) {
946
+ const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
947
+ const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
948
+ const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
949
+ if ( isOccurringTimeEarlier ) {
950
+ findissueEdgeApp = {
951
+ ticketId: ticket.ticketId,
952
+ edgelog: findissue,
953
+ storeId: ticket.basicDetails.storeId,
954
+ primary: 'Internet Issues',
955
+ secondary: [ 'Slow Internet Speed' ],
956
+ };
957
+ updateIssue( findissueEdgeApp );
958
+ finalresult.push( findissueEdgeApp );
959
+ // console.log( findissueEdgeApp );
960
+ }
961
+ }
962
+ }
963
+ }
964
+ }
965
+ res.sendSuccess( { count: finalresult.length, result: finalresult } );
966
+ } catch ( error ) {
967
+ logger.error( { error: error, function: 'camAngleChangeList' } );
968
+ res.sendError( error, 500 );
969
+ }
970
+ }
971
+ function bytesToMB( bytes ) {
972
+ return bytes / ( 1024 * 1024 );
973
+ }
974
+
975
+ export async function updateIssue( data ) {
976
+ try {
977
+ let Ticket = await findOneTangoTicket(
978
+ {
979
+ ticketId: data.ticketId,
980
+ },
981
+ );
982
+
983
+ data.issueType = Ticket.issueType;
984
+ data.basicDetails = Ticket.basicDetails;
985
+ data.ticketDetails = Ticket.ticketDetails;
986
+ data.ticketActivity = Ticket.ticketActivity;
987
+ if ( data.primary && data.secondary && data.secondary.length ) {
988
+ let primaryReason = await findOneinfraReason( { name: data.primary } );
989
+ if ( !primaryReason ) {
990
+ return res.sendError( 'Primary Reason Not exists in database', 500 );
991
+ }
992
+ const secondary = [];
993
+ const steptoReslove = [];
994
+ for ( let i = 0; i < data.secondary.length; i++ ) {
995
+ let secondaryReason = await findOneinfraReason( { name: data.secondary[i] } );
996
+ if ( !secondaryReason ) {
997
+ return res.sendError( `secondary Reason - ${data.secondary[i]} Not exists in database`, 500 );
998
+ }
999
+ secondary.push( {
1000
+ name: secondaryReason.name,
1001
+ } );
1002
+ let resolveSteps = [];
1003
+ for ( let i = 0; i < secondaryReason.stepstoResolve.length; i++ ) {
1004
+ resolveSteps.push( {
1005
+ name: secondaryReason.stepstoResolve[i].name,
1006
+ } );
1007
+ }
1008
+ steptoReslove.push( {
1009
+ primaryIssue: secondaryReason.name,
1010
+ secondaryIsssue: [ ...resolveSteps ],
1011
+ } );
1012
+ }
1013
+
1014
+ data.ticketActivity.push( {
1015
+ actionType: 'issueUpdate',
1016
+ actionBy: 'automated',
1017
+ IdentifiedBy: 'Tango',
1018
+ timeStamp: new Date(),
1019
+ reasons: [ {
1020
+ primaryIssue: primaryReason.name,
1021
+ secondaryIssue: secondary,
1022
+ } ],
1023
+ },
1024
+ );
1025
+ } else {
1026
+ if ( data.primary == 'Application Issues' ) {
1027
+ data.ticketActivity.push( {
1028
+ actionType: 'issueUpdate',
1029
+ actionBy: 'automated',
1030
+ timeStamp: new Date(),
1031
+ IdentifiedBy: 'Tango',
1032
+ reasons: [ {
1033
+ primaryIssue: data.primary,
1034
+ secondaryIssue: [],
1035
+ } ],
1036
+ },
1037
+ );
1038
+ }
1039
+ }
1040
+ if ( data.issueType == 'infra' ) {
1041
+ let client = await findOneClient( { clientId: data.basicDetails.clientId }, { ticketConfigs: 1 } );
1042
+ let statusCheckAlertTime = dayjs().add( client.ticketConfigs.statusCheckAlert, 'hours' ).format( 'YYYY-MM-DD hh:mm' );
1043
+ data.ticketActivity.push( {
1044
+ actionType: 'statusCheck',
1045
+ timeStamp: statusCheckAlertTime,
1046
+ actionBy: 'Tango',
1047
+ IdentifiedBy: 'Tango',
1048
+ timeStamp: new Date(),
1049
+ statusCheckAlertTime: statusCheckAlertTime,
1050
+ } );
1051
+ }
1052
+ let query = {
1053
+ 'ticketActivity': data.ticketActivity,
1054
+ 'ticketDetails.issueIdentifiedDate': new Date(),
1055
+ 'ticketDetails.issueStatus': 'identified',
1056
+ 'status': 'inprogress',
1057
+ };
1058
+ await updateOneTangoTicket( { ticketId: data.ticketId }, query );
1059
+ // console.log( data );
1060
+ } catch ( error ) {
1061
+ logger.error( { error: error, function: 'updateAutomaticIssue' } );
1062
+ res.sendError( error, 500 );
1063
+ }
1064
+ }
1065
+
@@ -330,6 +330,7 @@ export async function edgeAppLogTable( req, res ) {
330
330
  };
331
331
  const downtime = await getOpenSearchData( 'live_downtime_hourly', downTimeQuery );
332
332
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
333
+ // console.log( obj.hour, streamwiseDowntime );
333
334
  if ( streamwiseDowntime.length > 0 ) {
334
335
  const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
335
336
  return accumulator + currentValue.down_time;
@@ -4,7 +4,7 @@ import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
4
4
  import { validateDetails, bulkvalidateDetails, validateTicket, bulkvalidateTicket, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
5
5
  import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons,
6
6
  secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments,
7
- updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, infraTable, assignTicket, installationTable } from '../controllers/infra.controllers.js';
7
+ updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, infraTable, storeFilter, assignTicket, installationTable } from '../controllers/infra.controllers.js';
8
8
 
9
9
 
10
10
  export const infraRouter = express.Router();
@@ -67,3 +67,7 @@ infraRouter.post( '/assignTicket', isAllowedSessionHandler, authorize( {
67
67
  userType: [ 'client', 'tango' ], access: [
68
68
  { featureName: 'manage', name: 'tickets', permissions: [ 'isEdit', 'isView' ] } ],
69
69
  } ), assignTicket );
70
+ infraRouter.post( '/storeFilter', isAllowedSessionHandler, authorize( {
71
+ userType: [ 'client', 'tango' ], access: [
72
+ { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
73
+ } ), storeFilter );
@@ -2,7 +2,7 @@
2
2
  import express from 'express';
3
3
  import {
4
4
  migrateClient, migrateStores, basicList, clientList, setTicketTime, downStoresList,
5
- openTicketList, assigntoUser, updateRefreshTicket, closeTicket, camAngleChangeReport, spocmailchange, emailUserList, infraReportSent,
5
+ openTicketList, assigntoUser, updateRefreshTicket, closeTicket, edgeApplogsCheck, camAngleChangeReport, spocmailchange, emailUserList, infraReportSent,
6
6
  } from '../controllers/internalInfra.controller.js';
7
7
 
8
8
  export const internalInfraRouter = express.Router();
@@ -21,5 +21,6 @@ internalInfraRouter.get( '/emailUserList', emailUserList );
21
21
  internalInfraRouter.post( '/infraReportSent', infraReportSent );
22
22
  internalInfraRouter.post( '/spocmailchange', spocmailchange );
23
23
  internalInfraRouter.post( '/camAngleChangeReport', camAngleChangeReport );
24
+ internalInfraRouter.post( '/edgeApplogsCheck', edgeApplogsCheck );
24
25
 
25
26
 
@@ -325,7 +325,6 @@ export async function InfraAlert( req, res, next ) {
325
325
  await updateOneStore( { storeId: req.body.basicDetails.storeId }, { 'ticketConfigs.hibernation': new Date( req.body.hibernationDays ) } );
326
326
 
327
327
  await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'hibernation': new Date( req.body.hibernationDays ) } );
328
- console.log( req.body.ticketActivity );
329
328
  } else {
330
329
  if ( req.body.issueType == 'infra' ) {
331
330
  let client = await findOneClient( { clientId: req.body.basicDetails.clientId }, { ticketConfigs: 1 } );