Skip to content

fix: deprecate latest in app store app version #4896

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

Merged
merged 5 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package appStoreDiscoverRepository

import (
"fmt"
appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean"
"github.com/devtron-labs/devtron/pkg/sql"
"github.com/go-pg/pg"
Expand Down Expand Up @@ -114,27 +115,33 @@ func updateFindWithFilterQuery(filter *appStoreBean.AppStoreFilter, updateAction
query = " ch.name as chart_name, das.id as docker_artifact_store_id"
}
}

latestAppStoreVersionQuery := " SELECT MAX(asv.id) as id " +
" FROM app_store_application_version asv " +
" INNER JOIN app_store aps ON (asv.app_store_id = aps.id and aps.active = true) " +
" GROUP BY asv.app_store_id "

if updateAction == QUERY_JOIN_UPDTAE {
if len(filter.ChartRepoId) > 0 && len(filter.RegistryId) > 0 {
query = " LEFT JOIN chart_repo ch ON (aps.chart_repo_id = ch.id and ch.deleted IS FALSE)" +
" LEFT JOIN docker_artifact_store das ON aps.docker_artifact_store_id = das.id" +
" LEFT JOIN oci_registry_config oci ON oci.docker_artifact_store_id = das.id" +
" WHERE (asv.latest IS TRUE AND (ch.active IS TRUE OR (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)))" +
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) +
" AND (ch.id IN (?) OR das.id IN (?))"
} else if len(filter.RegistryId) > 0 {
query = " LEFT JOIN docker_artifact_store das ON aps.docker_artifact_store_id = das.id" +
" LEFT JOIN oci_registry_config oci ON oci.docker_artifact_store_id = das.id" +
" WHERE asv.latest IS TRUE AND (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)" +
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) +
" AND das.id IN (?)"
} else if len(filter.ChartRepoId) > 0 {
query = " LEFT JOIN chart_repo ch ON (aps.chart_repo_id = ch.id and ch.deleted IS FALSE)" +
" WHERE asv.latest IS TRUE AND ch.active IS TRUE" +
fmt.Sprintf(" WHERE asv.id IN (%s) AND ch.active IS TRUE", latestAppStoreVersionQuery) +
" AND ch.id IN (?)"
} else {
query = " LEFT JOIN chart_repo ch ON (aps.chart_repo_id = ch.id and ch.deleted IS FALSE)" +
" LEFT JOIN docker_artifact_store das ON aps.docker_artifact_store_id = das.id" +
" LEFT JOIN oci_registry_config oci ON oci.docker_artifact_store_id = das.id" +
" WHERE (asv.latest IS TRUE AND (ch.active IS TRUE OR (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)))"
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)
}
}
return query
Expand Down Expand Up @@ -249,7 +256,7 @@ func (impl *AppStoreApplicationVersionRepositoryImpl) FindByAppStoreName(name st

func (impl *AppStoreApplicationVersionRepositoryImpl) SearchAppStoreChartByName(chartName string) ([]*appStoreBean.ChartRepoSearch, error) {
var chartRepos []*appStoreBean.ChartRepoSearch
//eryTemp := "select asv.version, asv.icon,asv.deprecated ,asv.id as app_store_application_version_id, aps.*, ch.name as chart_name from app_store_application_version asv inner join app_store aps on asv.app_store_id = aps.id inner join chart_repo ch on aps.chart_repo_id = ch.id where asv.latest is TRUE order by aps.name asc;"
// eryTemp := "select asv.version, asv.icon,asv.deprecated ,asv.id as app_store_application_version_id, aps.*, ch.name as chart_name from app_store_application_version asv inner join app_store aps on asv.app_store_id = aps.id inner join chart_repo ch on aps.chart_repo_id = ch.id where asv.latest is TRUE order by aps.name asc;"
queryTemp := "select asv.id as app_store_application_version_id, asv.version, asv.deprecated, aps.id as chart_id," +
" aps.name as chart_name, chr.id as chart_repo_id, chr.name as chart_repo_name" +
" from app_store_application_version asv" +
Expand Down
4 changes: 4 additions & 0 deletions scripts/sql/235_app_atore_application.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE app_store_application_version ALTER COLUMN "icon" TYPE VARCHAR(250);
ALTER TABLE app_store_application_version ALTER COLUMN "source" TYPE VARCHAR(250);
ALTER TABLE app_store_application_version ALTER COLUMN "home" TYPE VARCHAR(100);
ALTER TABLE app_store_application_version ALTER COLUMN "name" TYPE VARCHAR(100);
4 changes: 4 additions & 0 deletions scripts/sql/235_app_store_application_version.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE app_store_application_version ALTER COLUMN "icon" TYPE VARCHAR(512);
ALTER TABLE app_store_application_version ALTER COLUMN "source" TYPE VARCHAR(512);
ALTER TABLE app_store_application_version ALTER COLUMN "home" TYPE VARCHAR(256);
ALTER TABLE app_store_application_version ALTER COLUMN "name" TYPE VARCHAR(256);
Loading