Skip to content

Commit 0b282fc

Browse files
committed
RHINENG-24787: simplify system load and go directly into SystemPlatformV2
1 parent 89a4dc5 commit 0b282fc

4 files changed

Lines changed: 10 additions & 302 deletions

File tree

base/models/models.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ func (SystemPatch) TableName() string {
129129
// and do not pass it to gorm.DB.Model as a single-table model—load it with explicit
130130
// SQL or Table/Joins on system_inventory and system_patch.
131131
type SystemPlatformV2 struct {
132-
Inventory SystemInventory
133-
Patch SystemPatch
132+
Inventory SystemInventory `gorm:"embedded"`
133+
Patch SystemPatch `gorm:"embedded"`
134134
}
135135

136136
func (v *SystemPlatformV2) GetInventoryID() string {

evaluator/evaluate.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,11 +680,14 @@ func loadSystemData(accountID int, inventoryID string) (*models.SystemPlatformV2
680680
tStart := time.Now()
681681
defer utils.ObserveSecondsSince(tStart, evaluationPartDuration.WithLabelValues("data-loading"))
682682

683-
v2, err := loadSystemPlatformV2(database.DB, accountID, inventoryID)
684-
if err != nil {
685-
return nil, err
686-
}
687-
return v2, nil
683+
var system models.SystemPlatformV2
684+
err := database.DB.Table("system_inventory si").
685+
Select("si.*, sp.*").
686+
Joins("JOIN system_patch sp ON sp.system_id = si.id AND sp.rh_account_id = si.rh_account_id").
687+
Where("si.rh_account_id = ?", accountID).
688+
Where("si.inventory_id = ?::uuid", inventoryID).
689+
Find(&system).Error
690+
return &system, err
688691
}
689692

690693
func validSystem(accountID int, systemID int64) bool {

evaluator/system_platform_v2_load.go

Lines changed: 0 additions & 204 deletions
This file was deleted.

evaluator/system_platform_v2_load_test.go

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)