MCPcopy Index your code
hub / github.com/cloudgraphdev/cli / pushData

Method pushData

src/reports/scan-report.ts:66–108  ·  view source on GitHub ↗
({ service, type, result }: pushDataParams)

Source from the content-addressed store, hash-verified

64 }
65
66 pushData({ service, type, result }: pushDataParams): void {
67 if (
68 servicesToIgnore.some(ignore => this.containsService(ignore, service))
69 ) {
70 return
71 }
72 const status = this.getStatus(result)
73 if (this.isInTable(service)) {
74 this.internalTable.data = this.internalTable.data.map(val => {
75 if (Object.keys(val).includes(service)) {
76 const [count, oldStatus] = val[service]
77
78 // Handle count type of data push
79 if (type === scanDataType.count) {
80 const newCount: number = 1 + Number(count)
81 return { [service]: [String(newCount), status] }
82 }
83
84 // Handle status, we do not want to "upgrade" from a failed or warning status to pass
85 let newStatus = status
86 if (oldStatus.includes(statusKeyWords.data)) {
87 newStatus = oldStatus
88 }
89 if (
90 oldStatus.includes(statusKeyWords.connections) &&
91 !status.includes(statusKeyWords.data)
92 ) {
93 newStatus = oldStatus
94 }
95 return { [service]: [`${count}`, newStatus] }
96 }
97 // Handle parts of the table that dont need to update
98 return val
99 })
100 } else {
101 this.internalTable.data.push({
102 [service]: [type === scanDataType.count ? '1' : '0', status],
103 })
104 }
105 if (type === scanDataType.count) {
106 this.incrementTotalTable()
107 }
108 }
109
110 private incrementTotalTable(): void {
111 const totalIndex = this.internalTable.data.findIndex(val => {

Callers 4

getConnectedEntityFunction · 0.45

Calls 5

containsServiceMethod · 0.95
getStatusMethod · 0.95
isInTableMethod · 0.95
incrementTotalTableMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected