modify code when project list length is 0

This commit is contained in:
wemeya 2016-05-13 16:39:22 +08:00
parent c5b1b86d89
commit d30fc97b3f
2 changed files with 7 additions and 4 deletions

View File

@ -57,12 +57,16 @@ func (s *StatisticAPI) Get() {
log.Errorf("Error occured in QueryProject, error: %v", err)
s.CustomAbort(http.StatusInternalServerError, "Internal error.")
}
proMap := map[string]int{}
isAdmin, err := dao.IsAdminRole(s.userID)
if err != nil {
log.Errorf("Error occured in check admin, error: %v", err)
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 {
proMap["total_project_count"] = len(projectList)
proMap["total_repo_count"] = getTotalRepoCount()

View File

@ -113,9 +113,8 @@ func QueryProject(query models.Project) ([]models.Project, error) {
sql += " order by p.name "
var r []models.Project
_, err0 := o.Raw(sql, queryParam).QueryRows(&r)
if err0 != nil {
_, err := o.Raw(sql, queryParam).QueryRows(&r)
if err != nil {
return nil, err
}
if isAdmin {