Skip to content

Commit

Permalink
Merge pull request #1524 from afumagalli98/1523
Browse files Browse the repository at this point in the history
Refactored OracleDatabasePartitioning
  • Loading branch information
afumagalli98 committed Apr 12, 2023
2 parents 1e6438c + ff0ebd7 commit 3acfc19
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 86 deletions.
21 changes: 9 additions & 12 deletions api-service/controller/oracle_database_partitionings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ func TestListOracleDatabasePartitionings_Success(t *testing.T) {

result := []dto.OracleDatabasePartitioning{
{
Hostname: "hostname",
DatabaseName: "databasename",
Owner: "ownername",
SegmentName: "segmentname",
PartitionName: "partitionname",
SegmentType: "segmentype",
Mb: 100,
Hostname: "hostname",
DatabaseName: "databasename",
Owner: "ownername",
SegmentName: "segmentname",
Count: 1,
Mb: 100,
},
}

Expand Down Expand Up @@ -96,8 +95,7 @@ func TestGetOracleDatabasePartitioningsXLSX_Success(t *testing.T) {
"PDB Name",
"Owner",
"Segment Name",
"Partition Name",
"Segment Type",
"Count",
"Mb",
}

Expand Down Expand Up @@ -129,7 +127,6 @@ func TestGetOracleDatabasePartitioningsXLSX_Success(t *testing.T) {
assert.Equal(t, "PDB Name", sp.GetCellValue("Partitioning", "C1"))
assert.Equal(t, "Owner", sp.GetCellValue("Partitioning", "D1"))
assert.Equal(t, "Segment Name", sp.GetCellValue("Partitioning", "E1"))
assert.Equal(t, "Partition Name", sp.GetCellValue("Partitioning", "F1"))
assert.Equal(t, "Segment Type", sp.GetCellValue("Partitioning", "G1"))
assert.Equal(t, "Mb", sp.GetCellValue("Partitioning", "H1"))
assert.Equal(t, "Count", sp.GetCellValue("Partitioning", "F1"))
assert.Equal(t, "Mb", sp.GetCellValue("Partitioning", "G1"))
}
28 changes: 13 additions & 15 deletions api-service/database/oracle_database_partitionings.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ func (md *MongoDatabase) FindAllOracleDatabasePartitionings(filter dto.GlobalFil
bson.M{"$unwind": bson.M{"path": "$features.oracle.database.databases"}},
bson.M{"$unwind": bson.M{"path": "$features.oracle.database.databases.partitionings"}},
bson.M{"$project": bson.M{
"hostname": 1,
"databaseName": "$features.oracle.database.databases.uniqueName",
"owner": "$features.oracle.database.databases.partitionings.owner",
"segmentName": "$features.oracle.database.databases.partitionings.segmentName",
"partitionName": "$features.oracle.database.databases.partitionings.partitionName",
"segmentType": "$features.oracle.database.databases.partitionings.segmentType",
"mb": "$features.oracle.database.databases.partitionings.mb",
"hostname": 1,
"databaseName": "$features.oracle.database.databases.uniqueName",
"owner": "$features.oracle.database.databases.partitionings.owner",
"segmentName": "$features.oracle.database.databases.partitionings.segmentName",
"count": "$features.oracle.database.databases.partitionings.count",
"mb": "$features.oracle.database.databases.partitionings.mb",
}},
),
)
Expand Down Expand Up @@ -68,14 +67,13 @@ func (md *MongoDatabase) FindAllOraclePDBPartitionings(filter dto.GlobalFilter)
bson.M{"$unwind": bson.M{"path": "$features.oracle.database.databases.pdbs"}},
bson.M{"$unwind": bson.M{"path": "$features.oracle.database.databases.pdbs.partitionings"}},
bson.M{"$project": bson.M{
"hostname": 1,
"databaseName": "$features.oracle.database.databases.uniqueName",
"pdb": "$features.oracle.database.databases.pdbs.name",
"owner": "$features.oracle.database.databases.pdbs.partitionings.owner",
"segmentName": "$features.oracle.database.databases.pdbs.partitionings.segmentName",
"partitionName": "$features.oracle.database.databases.pdbs.partitionings.partitionName",
"segmentType": "$features.oracle.database.databases.pdbs.partitionings.segmentType",
"mb": "$features.oracle.database.databases.pdbs.partitionings.mb",
"hostname": 1,
"databaseName": "$features.oracle.database.databases.uniqueName",
"pdb": "$features.oracle.database.databases.pdbs.name",
"owner": "$features.oracle.database.databases.pdbs.partitionings.owner",
"segmentName": "$features.oracle.database.databases.pdbs.partitionings.segmentName",
"count": "$features.oracle.database.databases.pdbs.partitionings.count",
"mb": "$features.oracle.database.databases.pdbs.partitionings.mb",
}},
),
)
Expand Down
15 changes: 7 additions & 8 deletions api-service/dto/oracle_database_partitioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ package dto

// OracleDatabasePartitioning holds the informations about a partitioning.
type OracleDatabasePartitioning struct {
Hostname string `json:"hostname" bson:"hostname"`
DatabaseName string `json:"databaseName" bson:"databaseName"`
Owner string `json:"owner" bson:"owner"`
SegmentName string `json:"segmentName" bson:"segmentName"`
PartitionName string `json:"partitionName" bson:"partitionName"`
SegmentType string `json:"segmentType" bson:"segmentType"`
Mb float64 `json:"mb" bson:"mb"`
Pdb string `json:"pdb,omitempty" bson:"pdb,omitempty"`
Hostname string `json:"hostname" bson:"hostname"`
DatabaseName string `json:"databaseName" bson:"databaseName"`
Owner string `json:"owner" bson:"owner"`
SegmentName string `json:"segmentName" bson:"segmentName"`
Count int `json:"count" bson:"count"`
Mb float64 `json:"mb" bson:"mb"`
Pdb string `json:"pdb,omitempty" bson:"pdb,omitempty"`
}
9 changes: 3 additions & 6 deletions api-service/service/oracle_database_partitionings.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ func (as *APIService) CreateOracleDatabasePartitioningsXlsx(filter dto.GlobalFil
"PDB Name",
"Owner",
"Segment Name",
"Partition Name",
"Segment Type",
"Count",
"Mb",
}

Expand All @@ -78,8 +77,7 @@ func (as *APIService) CreateOracleDatabasePartitioningsXlsx(filter dto.GlobalFil
sheets.SetCellValue(sheet, nextAxis(), "")
sheets.SetCellValue(sheet, nextAxis(), val.Owner)
sheets.SetCellValue(sheet, nextAxis(), val.SegmentName)
sheets.SetCellValue(sheet, nextAxis(), val.PartitionName)
sheets.SetCellValue(sheet, nextAxis(), val.SegmentType)
sheets.SetCellValue(sheet, nextAxis(), val.Count)
sheets.SetCellValue(sheet, nextAxis(), val.Mb)
}

Expand All @@ -90,8 +88,7 @@ func (as *APIService) CreateOracleDatabasePartitioningsXlsx(filter dto.GlobalFil
sheets.SetCellValue(sheet, nextAxis(), valPdb.Pdb)
sheets.SetCellValue(sheet, nextAxis(), valPdb.Owner)
sheets.SetCellValue(sheet, nextAxis(), valPdb.SegmentName)
sheets.SetCellValue(sheet, nextAxis(), valPdb.PartitionName)
sheets.SetCellValue(sheet, nextAxis(), valPdb.SegmentType)
sheets.SetCellValue(sheet, nextAxis(), valPdb.Count)
sheets.SetCellValue(sheet, nextAxis(), valPdb.Mb)
}

Expand Down
6 changes: 2 additions & 4 deletions api-service/service/oracle_database_partitionings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ func TestListOracleDatabasePartitionings_Success(t *testing.T) {
DatabaseName: "databasename",
Owner: "ownername",
SegmentName: "segmentname",
PartitionName: "partitionname",
SegmentType: "segmentype",
Count: 1,
Mb: 100,
},
}
Expand All @@ -54,8 +53,7 @@ func TestListOracleDatabasePartitionings_Success(t *testing.T) {
Pdb: "pdbname",
Owner: "ownername",
SegmentName: "segmentname",
PartitionName: "partitionname",
SegmentType: "segmentype",
Count: 1,
Mb: 100,
},
}
Expand Down
Loading

0 comments on commit 3acfc19

Please sign in to comment.