From c89a50c536fee9e05034121fcf3a287de2493358 Mon Sep 17 00:00:00 2001 From: Michael Mraka Date: Fri, 6 Oct 2023 13:43:17 +0200 Subject: [PATCH] RHINENG-2281: remove system_package table from /packages/version --- base/database/utils.go | 7 ------- base/models/models.go | 4 ---- manager/controllers/package_versions.go | 4 ++-- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/base/database/utils.go b/base/database/utils.go index f16dd0cb9..1f1176d80 100644 --- a/base/database/utils.go +++ b/base/database/utils.go @@ -34,13 +34,6 @@ func PackageSystemDataShort(tx *gorm.DB, accountID int) *gorm.DB { Where("pd.rh_account_id = ?", accountID) } -func SystemPackages(tx *gorm.DB, accountID int, groups map[string]string) *gorm.DB { - return Systems(tx, accountID, groups). - Joins("JOIN system_package2 spkg on spkg.system_id = sp.id AND spkg.rh_account_id = ?", accountID). - Joins("JOIN package p on p.id = spkg.package_id"). - Joins("JOIN package_name pn on pn.id = spkg.name_id") -} - func SystemPackageData(tx *gorm.DB, accountID int, groups map[string]string) *gorm.DB { return Systems(tx, accountID, groups). Joins(`JOIN (SELECT system_id, diff --git a/base/models/models.go b/base/models/models.go index c875a6931..84839cd60 100644 --- a/base/models/models.go +++ b/base/models/models.go @@ -122,10 +122,6 @@ type SystemPackage struct { ApplicableID *int64 } -func (SystemPackage) TableName() string { - return "system_package2" -} - type PackageUpdate struct { EVRA string `json:"evra"` Advisory string `json:"-"` // don't show it in API, we can probably remove it completely later diff --git a/manager/controllers/package_versions.go b/manager/controllers/package_versions.go index 31b1f61a5..e0d04eecd 100644 --- a/manager/controllers/package_versions.go +++ b/manager/controllers/package_versions.go @@ -46,10 +46,10 @@ func packagesNameID(db *gorm.DB, pkgName string) *gorm.DB { } func packageVersionsQuery(db *gorm.DB, acc int, groups map[string]string, packageNameIDs []int) *gorm.DB { - query := database.SystemPackages(db, acc, groups). + query := database.SystemPackageData(db, acc, groups). Distinct(PackageVersionSelect). Where("sp.stale = false"). - Where("spkg.name_id in (?)", packageNameIDs) + Where("p.name_id in (?)", packageNameIDs) return query }