Skip to content

Commit 72b3712

Browse files
authored
Merge pull request #2097 from afumagalli98/feat/2096
feat: handle empty fields in cluster Veritas licenses processing
2 parents 0885423 + 47bc809 commit 72b3712

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

api-service/database/host_cluster_veritas.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ func (md *MongoDatabase) FindClusterVeritasLicenses(filter dto.GlobalFilter) ([]
3838
},
3939
},
4040
},
41-
bson.D{{Key: "$unwind", Value: bson.D{{Key: "path", Value: "$features.oracle.database.databases"}}}},
42-
bson.D{{Key: "$unwind", Value: bson.D{{Key: "path", Value: "$features.oracle.database.databases.licenses"}}}},
41+
bson.D{{Key: "$unwind", Value: bson.D{
42+
{Key: "path", Value: "$features.oracle.database.databases"},
43+
{Key: "preserveNullAndEmptyArrays", Value: true},
44+
}}},
45+
bson.D{{Key: "$unwind", Value: bson.D{
46+
{Key: "path", Value: "$features.oracle.database.databases.licenses"},
47+
{Key: "preserveNullAndEmptyArrays", Value: true},
48+
}}},
4349
bson.D{
4450
{Key: "$lookup",
4551
Value: bson.D{

api-service/service/host_cluster_veritas.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ func removeDuplicates(licenses []dto.ClusterVeritasLicense) []dto.ClusterVeritas
6868
unique := []dto.ClusterVeritasLicense{}
6969

7070
for _, license := range licenses {
71-
if license.ID == "" {
71+
emptyLicense := license.LicenseTypeID == "" && license.Metric == "" && license.Description == ""
72+
if license.ID == "" || emptyLicense {
7273
continue
7374
}
7475

0 commit comments

Comments
 (0)