You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: latest version in default cluster and on UI (#5259)
* fix for latest version in default cluster and on UI
* wire gen
* defining variable for isOCIRepo
* adding app store repository in provider
* wip: adding latest check in chart search query
* updating indentation and comment
query=" ch.name as chart_name, das.id as docker_artifact_store_id"
99
100
}
100
101
}
102
+
//for chart repos, created (derived through index.yaml) column of app_store_application_version is used for finding latest version and for oci repo id is used (because created is null)
103
+
latestAppStoreVersionQueryForChartRepo:=" SELECT MAX(created) as created "+
104
+
" FROM app_store_application_version asv "+
105
+
" INNER JOIN app_store aps ON (asv.app_store_id = aps.id and aps.active = true and aps.chart_repo_id is NOT NULL) "+
106
+
" GROUP BY asv.app_store_id "
101
107
102
-
latestAppStoreVersionQuery:=" SELECT MAX(asv.id) as id "+
108
+
latestAppStoreVersionQueryForOCIRepo:=" SELECT MAX(asv.id) as id "+
103
109
" FROM app_store_application_version asv "+
104
-
" INNER JOIN app_store aps ON (asv.app_store_id = aps.id and aps.active = true) "+
110
+
" INNER JOIN app_store aps ON (asv.app_store_id = aps.id and aps.active = true and aps.docker_artifact_store_id is NOT NULL) "+
105
111
" GROUP BY asv.app_store_id "
106
112
113
+
combinedWhereClause:=fmt.Sprintf("( (asv.created IN (%s) and aps.chart_repo_id is not null ) or (asv.id IN (%s) and aps.docker_artifact_store_id is not null) )", latestAppStoreVersionQueryForChartRepo, latestAppStoreVersionQueryForOCIRepo)
query=" LEFT JOIN chart_repo ch ON (aps.chart_repo_id = ch.id and ch.deleted IS FALSE)"+
110
118
" LEFT JOIN docker_artifact_store das ON aps.docker_artifact_store_id = das.id"+
111
119
" LEFT JOIN oci_registry_config oci ON oci.docker_artifact_store_id = das.id"+
112
-
fmt.Sprintf(" WHERE (asv.id IN (%s) AND (ch.active IS TRUE OR (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)))", latestAppStoreVersionQuery) +
120
+
fmt.Sprintf(" WHERE ((%s) AND (ch.active IS TRUE OR (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)))", combinedWhereClause) +
113
121
" AND (ch.id IN (?) OR das.id IN (?))"
114
122
} elseiflen(filter.RegistryId) >0 {
115
123
query=" LEFT JOIN docker_artifact_store das ON aps.docker_artifact_store_id = das.id"+
116
124
" LEFT JOIN oci_registry_config oci ON oci.docker_artifact_store_id = das.id"+
117
-
fmt.Sprintf(" WHERE asv.id IN (%s) AND (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)", latestAppStoreVersionQuery) +
125
+
fmt.Sprintf(" WHERE asv.id IN (%s) AND (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)", latestAppStoreVersionQueryForOCIRepo) +
118
126
" AND das.id IN (?)"
119
127
} elseiflen(filter.ChartRepoId) >0 {
120
128
query=" LEFT JOIN chart_repo ch ON (aps.chart_repo_id = ch.id and ch.deleted IS FALSE)"+
121
-
fmt.Sprintf(" WHERE asv.id IN (%s) AND ch.active IS TRUE", latestAppStoreVersionQuery) +
129
+
fmt.Sprintf(" WHERE asv.created IN (%s) AND ch.active IS TRUE", latestAppStoreVersionQueryForChartRepo) +
122
130
" AND ch.id IN (?)"
123
131
} else {
124
132
query=" LEFT JOIN chart_repo ch ON (aps.chart_repo_id = ch.id and ch.deleted IS FALSE)"+
125
133
" LEFT JOIN docker_artifact_store das ON aps.docker_artifact_store_id = das.id"+
126
134
" LEFT JOIN oci_registry_config oci ON oci.docker_artifact_store_id = das.id"+
127
-
fmt.Sprintf(" WHERE (asv.id IN (%s) AND (ch.active IS TRUE OR (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)))", latestAppStoreVersionQuery)
135
+
fmt.Sprintf(" WHERE (%s AND (ch.active IS TRUE OR (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)))", combinedWhereClause)
queryTemp:="SELECT asv.id AS app_store_application_version_id FROM app_store_application_version AS asv JOIN app_store AS ap ON asv.app_store_id = ap.id WHERE ap.id = ? order by created desc limit 1;"
queryTemp:="SELECT MAX(asv.id) AS app_store_application_version_id FROM app_store_application_version AS asv JOIN app_store AS ap ON asv.app_store_id = ap.id WHERE ap.name = ?;"
queryTemp:="SELECT MAX(asv.id) AS app_store_application_version_id FROM app_store_application_version AS asv JOIN app_store AS ap ON asv.app_store_id = ap.id WHERE ap.id = ?;"
//for chart repos, created (derived through index.yaml) column of app_store_application_version is used for finding latest version and for oci repo id is used (because created is null)
239
255
queryTemp:="select asv.id as app_store_application_version_id, asv.version, asv.deprecated, aps.id as chart_id,"+
240
256
" aps.name as chart_name, chr.id as chart_repo_id, chr.name as chart_repo_name"+
241
257
" from app_store_application_version asv"+
242
258
" inner join app_store aps on asv.app_store_id = aps.id"+
243
259
" left join chart_repo chr on aps.chart_repo_id = chr.id"+
244
260
" left join docker_artifact_store das on aps.docker_artifact_store_id = das.id"+
245
-
" where aps.name like '%"+chartName+"%' and asv.id = (SELECT MAX(id) FROM app_store_application_version WHERE app_store_id = asv.app_store_id) and aps.active=true order by aps.name asc;"
261
+
" where aps.name like '%"+chartName+"%' and"+
262
+
"( "+
263
+
"( aps.docker_artifact_store_id is NOT NULL and asv.id = (SELECT MAX(id) FROM app_store_application_version WHERE app_store_id = asv.app_store_id))"+
264
+
" or "+
265
+
"(aps.chart_repo_id is NOT NULL and asv.created = (SELECT MAX(created) FROM app_store_application_version WHERE app_store_id = asv.app_store_id)) "+
0 commit comments