Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hotfix no pg rows for app listing #5906

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions internal/sql/repository/app/AppRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,14 @@ func (repo AppRepositoryImpl) FindAppAndProjectByAppName(appName string) (*App,

func (repo AppRepositoryImpl) fixMultipleHelmAppsWithSameName(appName string) error {
// updating installed apps setting app_id = max app_id
repo.logger.Infow(" duplicates found - marking app inactive", "appName", appName)
appTypeArr := pg.In([]int{int(helper.ChartStoreApp), int(helper.ExternalChartStoreApp)})

installAppUpdateQuery := `update installed_apps set
app_id=(select max(id) as id from app where app_name = ?)
where app_id in (select id from app where app_name= ? )`
app_id=(select max(id) as id from app where app_name = ? and app_type in (?) )
where app_id in (select id from app where app_name= ? and app_type in (?) )`

_, err := repo.dbConnection.Exec(installAppUpdateQuery, appName, appName)
_, err := repo.dbConnection.Exec(installAppUpdateQuery, appName, appTypeArr, appName, appTypeArr)
if err != nil {
repo.logger.Errorw("error in updating maxAppId in installedApps", "appName", appName, "err", err)
return err
Expand All @@ -390,7 +393,8 @@ func (repo AppRepositoryImpl) fixMultipleHelmAppsWithSameName(appName string) er
// deleting all apps other than app with max id
_, err = repo.dbConnection.Model((*App)(nil)).
Set("active = ?", false).Set("updated_by = ?", SYSTEM_USER_ID).Set("updated_on = ?", time.Now()).
Where("id not in (?) ", maxAppIdQuery).Update()
Where("id not in (?) and app_name = ? and app_type in (?) ",
maxAppIdQuery, appName, appTypeArr).Update()

return nil
}
Expand Down
Loading