Skip to content

Commit

Permalink
after adding condition for deployed time sort (#3108)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aravind-2023 authored Mar 24, 2023
1 parent 9023af8 commit f91d223
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const (
)

const (
AppNameSortBy SortBy = "appNameSort"
AppNameSortBy SortBy = "appNameSort"
LastDeployedSortBy = "lastDeployedSort"
)

func (impl AppListingRepositoryQueryBuilder) BuildJobListingQuery(appIDs []int, statuses []string, sortOrder string) string {
Expand Down
14 changes: 14 additions & 0 deletions pkg/app/AppListingViewBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ func (impl *AppListingViewBuilderImpl) BuildView(fetchAppListingRequest FetchApp
return appContainersResponses[i].AppName > appContainersResponses[j].AppName
})
}
} else if helper.LastDeployedSortBy == fetchAppListingRequest.SortBy {
if fetchAppListingRequest.SortOrder == helper.Asc {
sort.Slice(appContainersResponses, func(i, j int) bool {
deployedTime1 := appContainersResponses[i].AppEnvironmentContainer[0].LastDeployedTime
deployedTime2 := appContainersResponses[j].AppEnvironmentContainer[0].LastDeployedTime
return deployedTime1 > deployedTime2
})
} else if fetchAppListingRequest.SortOrder == helper.Desc {
sort.Slice(appContainersResponses, func(i, j int) bool {
deployedTime1 := appContainersResponses[i].AppEnvironmentContainer[0].LastDeployedTime
deployedTime2 := appContainersResponses[j].AppEnvironmentContainer[0].LastDeployedTime
return deployedTime1 < deployedTime2
})
}
}
}
return appContainersResponses, nil
Expand Down

0 comments on commit f91d223

Please sign in to comment.