Unverified Commit 03885776 authored by erda-bot's avatar erda-bot Committed by GitHub
Browse files

fix: convert `project_id` to string (#4822) (#4830)


* feat: convert project_id to string

* feat: ut
Co-authored-by: default avatar悟空 <rainchan365@163.com>
parent 0821ee53
Showing with 18 additions and 1 deletion
+18 -1
......@@ -761,7 +761,7 @@ func (p *Project) fetchPodInfo(dto *apistructs.ProjectDTO) {
return
}
var podInfos []apistructs.PodInfo
if err := p.db.Find(&podInfos, map[string]interface{}{"project_id": dto.ID, "phase": "running"}).Error; err != nil {
if err := p.db.Find(&podInfos, RunningPodCond(dto.ID)).Error; err != nil {
logrus.WithError(err).WithField("project_id", dto.ID).
Warnln("failed to Find the namespaces info in the project")
return
......@@ -1584,3 +1584,10 @@ func (p *Project) ListUnblockAppCountsByProjectIDS(projectIDS []uint64) ([]model
}
return p.db.ListUnblockAppCountsByProjectIDS(projectIDS)
}
func RunningPodCond(projectID uint64) map[string]interface{} {
return map[string]interface{}{
"project_id": strconv.FormatUint(projectID, 10),
"phase": "running",
}
}
......@@ -398,3 +398,13 @@ func TestGetNotFoundProject(t *testing.T) {
_, err := p.Get(context.Background(), 1, true)
assert.Equal(t, dao.ErrNotFoundProject, err)
}
func TestRunningPodCond(t *testing.T) {
cond := RunningPodCond(1)
if cond["project_id"] != "1" {
t.Fatal("error")
}
if cond["phase"] != "running" {
t.Fatal("error")
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment