Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
using distinct to filter results
Browse files Browse the repository at this point in the history
Signed-off-by: Prafulla Mahindrakar <prafulla.mahindrakar@gmail.com>
  • Loading branch information
pmahindrakar-oss committed Apr 8, 2022
1 parent 47bb2ec commit 0e3915c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/repositories/gormimpl/launch_plan_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (r *LaunchPlanRepo) ListLaunchPlanIdentifiers(ctx context.Context, input in
// Scan the results into a list of launch plans
var launchPlans []models.LaunchPlan
timer := r.metrics.ListIdentifiersDuration.Start()
tx.Select([]string{Project, Domain, Name}).Group(identifierGroupBy).Scan(&launchPlans)
tx.Distinct([]string{Project, Domain, Name}).Group(identifierGroupBy).Scan(&launchPlans)
timer.Stop()
if tx.Error != nil {
return interfaces.LaunchPlanCollectionOutput{}, r.errorTransformer.ToFlyteAdminError(tx.Error)
Expand Down
6 changes: 3 additions & 3 deletions pkg/repositories/gormimpl/named_entity_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func getSubQueryJoin(db *gorm.DB, tableName string, input interfaces.ListNamedEn
Table(tableName).
Where(map[string]interface{}{Project: input.Project, Domain: input.Domain}).
Limit(input.Limit).
Group(identifierGroupBy).
Offset(input.Offset)
Offset(input.Offset).
Group(identifierGroupBy)

// Apply consistent sort ordering.
if input.SortParameter != nil {
Expand Down Expand Up @@ -198,7 +198,7 @@ func (r *NamedEntityRepo) List(ctx context.Context, input interfaces.ListNamedEn
var entities []models.NamedEntity
timer := r.metrics.ListDuration.Start()

tx.Select(getSelectForNamedEntity(innerJoinTableAlias, input.ResourceType)).Table(namedEntityMetadataTableName).Group(getGroupByForNamedEntity).Scan(&entities)
tx.Distinct(getSelectForNamedEntity(innerJoinTableAlias, input.ResourceType)).Table(namedEntityMetadataTableName).Group(getGroupByForNamedEntity).Scan(&entities)

timer.Stop()

Expand Down
2 changes: 1 addition & 1 deletion pkg/repositories/gormimpl/task_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (r *TaskRepo) ListTaskIdentifiers(ctx context.Context, input interfaces.Lis
// Scan the results into a list of tasks
var tasks []models.Task
timer := r.metrics.ListIdentifiersDuration.Start()
tx.Select([]string{Project, Domain, Name}).Group(identifierGroupBy).Scan(&tasks)
tx.Distinct([]string{Project, Domain, Name}).Group(identifierGroupBy).Scan(&tasks)
timer.Stop()
if tx.Error != nil {
return interfaces.TaskCollectionOutput{}, r.errorTransformer.ToFlyteAdminError(tx.Error)
Expand Down
2 changes: 1 addition & 1 deletion pkg/repositories/gormimpl/workflow_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (r *WorkflowRepo) ListIdentifiers(ctx context.Context, input interfaces.Lis
// Scan the results into a list of workflows
var workflows []models.Workflow
timer := r.metrics.ListIdentifiersDuration.Start()
tx.Select([]string{Project, Domain, Name}).Group(identifierGroupBy).Scan(&workflows)
tx.Distinct([]string{Project, Domain, Name}).Group(identifierGroupBy).Scan(&workflows)
timer.Stop()
if tx.Error != nil {
return interfaces.WorkflowCollectionOutput{}, r.errorTransformer.ToFlyteAdminError(tx.Error)
Expand Down

0 comments on commit 0e3915c

Please sign in to comment.