mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-27 04:35:16 +01:00
modify code when project list length is 0
This commit is contained in:
parent
c5b1b86d89
commit
d30fc97b3f
@ -57,12 +57,16 @@ func (s *StatisticAPI) Get() {
|
|||||||
log.Errorf("Error occured in QueryProject, error: %v", err)
|
log.Errorf("Error occured in QueryProject, error: %v", err)
|
||||||
s.CustomAbort(http.StatusInternalServerError, "Internal error.")
|
s.CustomAbort(http.StatusInternalServerError, "Internal error.")
|
||||||
}
|
}
|
||||||
proMap := map[string]int{}
|
|
||||||
isAdmin, err := dao.IsAdminRole(s.userID)
|
isAdmin, err := dao.IsAdminRole(s.userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error occured in check admin, error: %v", err)
|
log.Errorf("Error occured in check admin, error: %v", err)
|
||||||
s.CustomAbort(http.StatusInternalServerError, "Internal error.")
|
s.CustomAbort(http.StatusInternalServerError, "Internal error.")
|
||||||
}
|
}
|
||||||
|
proMap := map[string]int{}
|
||||||
|
proMap["my_project_count"] = 0
|
||||||
|
proMap["my_repo_count"] = 0
|
||||||
|
proMap["public_project_count"] = 0
|
||||||
|
proMap["public_repo_count"] = 0
|
||||||
if isAdmin {
|
if isAdmin {
|
||||||
proMap["total_project_count"] = len(projectList)
|
proMap["total_project_count"] = len(projectList)
|
||||||
proMap["total_repo_count"] = getTotalRepoCount()
|
proMap["total_repo_count"] = getTotalRepoCount()
|
||||||
|
@ -113,9 +113,8 @@ func QueryProject(query models.Project) ([]models.Project, error) {
|
|||||||
sql += " order by p.name "
|
sql += " order by p.name "
|
||||||
|
|
||||||
var r []models.Project
|
var r []models.Project
|
||||||
_, err0 := o.Raw(sql, queryParam).QueryRows(&r)
|
_, err := o.Raw(sql, queryParam).QueryRows(&r)
|
||||||
|
if err != nil {
|
||||||
if err0 != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if isAdmin {
|
if isAdmin {
|
||||||
|
Loading…
Reference in New Issue
Block a user