Skip to content

Commit 0e636ba

Browse files
authored
Merge pull request #1774 from afumagalli98/1739-1
Improved hosts missing db export API
2 parents b378744 + cc1c4d4 commit 0e636ba

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

api-service/database/hosts.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,28 @@ func (md *MongoDatabase) getHosts(mode string, filters dto.SearchHostsFilters, o
158158
model.TechnologyPostgreSQLPostgreSQL: "$features.postgresql.instances.name",
159159
model.TechnologyMongoDBMongoDB: "$features.mongodb.instances.name",
160160
},
161+
"isMissingDB": bson.D{
162+
{Key: "$concatArrays",
163+
Value: bson.A{
164+
bson.D{
165+
{Key: "$ifNull",
166+
Value: bson.A{
167+
"$features.oracle.database.unlistedRunningDatabases",
168+
bson.A{},
169+
},
170+
},
171+
},
172+
bson.D{
173+
{Key: "$ifNull",
174+
Value: bson.A{
175+
"$features.oracle.database.unretrievedDatabases",
176+
bson.A{},
177+
},
178+
},
179+
},
180+
},
181+
},
182+
},
161183
"technology": bson.D{
162184
{Key: "$switch",
163185
Value: bson.D{

api-service/database/hosts_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ func (m *MongodbSuite) TestGetHostDataSummaries() {
173173
Cluster: "Puzzait",
174174
Databases: map[string][]string{},
175175
Technology: "",
176+
IsMissingDB: []string{},
176177
},
177178
{
178179
ID: "5ea2d26d20d55cbdc35022b4",
@@ -206,8 +207,9 @@ func (m *MongodbSuite) TestGetHostDataSummaries() {
206207
VeritasClusterServer: false,
207208
VeritasClusterHostnames: []string(nil),
208209
},
209-
Databases: map[string][]string{},
210-
Technology: "",
210+
Databases: map[string][]string{},
211+
Technology: "",
212+
IsMissingDB: []string{},
211213
},
212214
{
213215
ID: "5e96ade270c184faca93fe36",
@@ -246,7 +248,8 @@ func (m *MongodbSuite) TestGetHostDataSummaries() {
246248
Databases: map[string][]string{
247249
"Oracle/Database": {"ERCOLE"},
248250
},
249-
Technology: "Oracle/Database",
251+
Technology: "Oracle/Database",
252+
IsMissingDB: []string{},
250253
},
251254
}
252255

@@ -307,6 +310,7 @@ func (m *MongodbSuite) TestGetHostDataSummaries() {
307310
VirtualizationNode: "s157-cb32c10a56c256746c337e21b3f82402",
308311
Cluster: "Puzzait",
309312
Technology: "Oracle/Database",
313+
IsMissingDB: []string{},
310314
Databases: map[string][]string{
311315
"Oracle/Database": {
312316
"ERCOLE"}}},
@@ -358,6 +362,7 @@ func (m *MongodbSuite) TestGetHostDataSummaries() {
358362
Cluster: "Puzzait",
359363
Databases: map[string][]string{},
360364
Technology: "",
365+
IsMissingDB: []string{},
361366
},
362367
}
363368
assert.Equal(t, expectedOut, out)

0 commit comments

Comments
 (0)