Skip to content

Commit

Permalink
RHINENG-10791: common installable/applicable packages join
Browse files Browse the repository at this point in the history
  • Loading branch information
psegedy committed Jul 1, 2024
1 parent 8b95416 commit c20584d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 5 additions & 0 deletions base/database/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,8 @@ func JoinAdvisoryMetadata(tx *gorm.DB) *gorm.DB {
func JoinAdvisoryType(tx *gorm.DB) *gorm.DB {
return tx.Joins("JOIN advisory_type at ON am.advisory_type_id = at.id")
}

func JoinInstallableApplicablePackages(tx *gorm.DB) *gorm.DB {
return tx.Joins("LEFT JOIN package pi ON pi.id = spkg.installable_id").
Joins("LEFT JOIN package pa ON pa.id = spkg.applicable_id")
}
5 changes: 2 additions & 3 deletions manager/controllers/package_systems.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ func packagesByNameQuery(db *gorm.DB, pkgName string) *gorm.DB {

func packageSystemsQuery(db *gorm.DB, acc int, groups map[string]string, packageName string, packageIDs []int,
) *gorm.DB {
query := database.SystemPackages(db, acc, groups, database.JoinTemplates).
query := database.SystemPackages(db, acc, groups,
database.JoinTemplates, database.JoinInstallableApplicablePackages).
Select(PackageSystemsSelect).
Joins("LEFT JOIN package pi ON pi.id = spkg.installable_id").
Joins("LEFT JOIN package pa ON pa.id = spkg.applicable_id").
Where("sp.stale = false").
Where("pn.name = ?", packageName).
Where("spkg.package_id in (?)", packageIDs)
Expand Down
4 changes: 1 addition & 3 deletions manager/controllers/system_packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ type SystemPackageDBLoad struct {
}

func systemPackageQuery(db *gorm.DB, account int, groups map[string]string, inventoryID string) *gorm.DB {
query := database.SystemPackages(db, account, groups).
Joins("LEFT JOIN package pi ON pi.id = spkg.installable_id").
Joins("LEFT JOIN package pa ON pa.id = spkg.applicable_id").
query := database.SystemPackages(db, account, groups, database.JoinInstallableApplicablePackages).
Joins("LEFT JOIN strings AS descr ON p.description_hash = descr.id").
Joins("LEFT JOIN strings AS sum ON p.summary_hash = sum.id").
Select(SystemPackagesSelect).
Expand Down

0 comments on commit c20584d

Please sign in to comment.