Skip to content

Commit da17f34

Browse files
feat: fetch all non deprecated plugins in list (#6135)
* fetch all non deprecated plugins * plugin metadata * refactor
1 parent 1ccca6c commit da17f34

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

pkg/plugin/GlobalPluginService.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func (impl *GlobalPluginServiceImpl) ListAllPlugins(stageTypeReq string) ([]*bea
228228

229229
//getting all plugins metadata(without tags)
230230
if len(stageTypeReq) == 0 {
231-
pluginsMetadata, err = impl.globalPluginRepository.GetMetaDataForAllPlugins()
231+
pluginsMetadata, err = impl.globalPluginRepository.GetMetaDataForAllPlugins(true)
232232
if err != nil {
233233
impl.logger.Errorw("error in getting plugins", "err", err)
234234
return nil, err
@@ -1749,7 +1749,7 @@ func (impl *GlobalPluginServiceImpl) GetPluginParentMetadataDtos(parentIdVsPlugi
17491749

17501750
func (impl *GlobalPluginServiceImpl) ListAllPluginsV2(filter *bean2.PluginsListFilter) (*bean2.PluginsDto, error) {
17511751
impl.logger.Infow("request received, ListAllPluginsV2", "filter", filter)
1752-
pluginVersionsMetadata, err := impl.globalPluginRepository.GetMetaDataForAllPlugins()
1752+
pluginVersionsMetadata, err := impl.globalPluginRepository.GetMetaDataForAllPlugins(true)
17531753
if err != nil {
17541754
impl.logger.Errorw("ListAllPluginsV2, error in getting plugins", "err", err)
17551755
return nil, err
@@ -1821,7 +1821,7 @@ func (impl *GlobalPluginServiceImpl) GetPluginDetailV2(queryParams bean2.GlobalP
18211821
}
18221822
queryParams.ParentPluginIds = append(queryParams.ParentPluginIds, additionalPluginParentIds...)
18231823
queryParams.ParentPluginIds = sliceUtil.GetUniqueElements(queryParams.ParentPluginIds)
1824-
pluginVersionsMetadata, err := impl.globalPluginRepository.GetMetaDataForAllPlugins()
1824+
pluginVersionsMetadata, err := impl.globalPluginRepository.GetMetaDataForAllPlugins(false)
18251825
if err != nil {
18261826
impl.logger.Errorw("GetPluginDetailV2, error in getting all plugins versions metadata", "err", err)
18271827
return nil, err
@@ -1884,7 +1884,7 @@ func (impl *GlobalPluginServiceImpl) GetAllUniqueTags() (*bean2.PluginTagsDto, e
18841884
}
18851885

18861886
func (impl *GlobalPluginServiceImpl) MigratePluginData() error {
1887-
pluginVersionsMetadata, err := impl.globalPluginRepository.GetMetaDataForAllPlugins()
1887+
pluginVersionsMetadata, err := impl.globalPluginRepository.GetMetaDataForAllPlugins(false)
18881888
if err != nil {
18891889
impl.logger.Errorw("MigratePluginData, error in getting plugins", "err", err)
18901890
return err

pkg/plugin/repository/GlobalPluginRepository.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ type PluginStageMapping struct {
326326
}
327327

328328
type GlobalPluginRepository interface {
329-
GetMetaDataForAllPlugins() ([]*PluginMetadata, error)
329+
GetMetaDataForAllPlugins(excludeDeprecated bool) ([]*PluginMetadata, error)
330330
GetMetaDataForPluginWithStageType(stageType int) ([]*PluginMetadata, error)
331331
GetMetaDataByPluginId(pluginId int) (*PluginMetadata, error)
332332
GetMetaDataByPluginIds(pluginIds []int) ([]*PluginMetadata, error)
@@ -403,12 +403,15 @@ func (impl *GlobalPluginRepositoryImpl) GetConnection() (dbConnection *pg.DB) {
403403
return impl.dbConnection
404404
}
405405

406-
func (impl *GlobalPluginRepositoryImpl) GetMetaDataForAllPlugins() ([]*PluginMetadata, error) {
406+
func (impl *GlobalPluginRepositoryImpl) GetMetaDataForAllPlugins(excludeDeprecated bool) ([]*PluginMetadata, error) {
407407
var plugins []*PluginMetadata
408-
err := impl.dbConnection.Model(&plugins).
408+
query := impl.dbConnection.Model(&plugins).
409409
Where("deleted = ?", false).
410-
Order("id").
411-
Select()
410+
Order("id")
411+
if excludeDeprecated {
412+
query = query.Where("is_deprecated = ?", false)
413+
}
414+
err := query.Select()
412415
if err != nil {
413416
impl.logger.Errorw("err in getting all plugins", "err", err)
414417
return nil, err
@@ -872,7 +875,7 @@ func (impl *GlobalPluginRepositoryImpl) GetAllFilteredPluginParentMetadata(searc
872875
var plugins []*PluginParentMetadata
873876
query := "select ppm.id, ppm.identifier,ppm.name,ppm.description,ppm.type,ppm.icon,ppm.deleted,ppm.created_by, ppm.created_on,ppm.updated_by,ppm.updated_on from plugin_parent_metadata ppm" +
874877
" inner join plugin_metadata pm on pm.plugin_parent_metadata_id=ppm.id"
875-
whereCondition := fmt.Sprintf(" where ppm.deleted=false AND pm.deleted=false AND pm.is_latest=true")
878+
whereCondition := fmt.Sprintf(" where ppm.deleted=false AND pm.deleted=false AND pm.is_latest=true and pm.is_deprecated=false")
876879
if len(tags) > 0 {
877880
tagFilterSubQuery := fmt.Sprintf("select ptr.plugin_id from plugin_tag_relation ptr inner join plugin_tag pt on ptr.tag_id =pt.id where pt.deleted =false and pt.name in (%s) group by ptr.plugin_id having count(ptr.plugin_id )=%d", helper.GetCommaSepratedStringWithComma(tags), len(tags))
878881
whereCondition += fmt.Sprintf(" AND pm.id in (%s)", tagFilterSubQuery)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- empty script to maintain script number common across repo
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- empty script to maintain script number common across repo

0 commit comments

Comments
 (0)