Skip to content

Commit 0388577

Browse files
erda-botdspo
andauthored
fix: convert project_id to string (#4822) (#4830)
* feat: convert project_id to string * feat: ut Co-authored-by: 悟空 <[email protected]>
1 parent 0821ee5 commit 0388577

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

modules/core-services/services/project/project.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ func (p *Project) fetchPodInfo(dto *apistructs.ProjectDTO) {
761761
return
762762
}
763763
var podInfos []apistructs.PodInfo
764-
if err := p.db.Find(&podInfos, map[string]interface{}{"project_id": dto.ID, "phase": "running"}).Error; err != nil {
764+
if err := p.db.Find(&podInfos, RunningPodCond(dto.ID)).Error; err != nil {
765765
logrus.WithError(err).WithField("project_id", dto.ID).
766766
Warnln("failed to Find the namespaces info in the project")
767767
return
@@ -1584,3 +1584,10 @@ func (p *Project) ListUnblockAppCountsByProjectIDS(projectIDS []uint64) ([]model
15841584
}
15851585
return p.db.ListUnblockAppCountsByProjectIDS(projectIDS)
15861586
}
1587+
1588+
func RunningPodCond(projectID uint64) map[string]interface{} {
1589+
return map[string]interface{}{
1590+
"project_id": strconv.FormatUint(projectID, 10),
1591+
"phase": "running",
1592+
}
1593+
}

modules/core-services/services/project/project_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,13 @@ func TestGetNotFoundProject(t *testing.T) {
398398
_, err := p.Get(context.Background(), 1, true)
399399
assert.Equal(t, dao.ErrNotFoundProject, err)
400400
}
401+
402+
func TestRunningPodCond(t *testing.T) {
403+
cond := RunningPodCond(1)
404+
if cond["project_id"] != "1" {
405+
t.Fatal("error")
406+
}
407+
if cond["phase"] != "running" {
408+
t.Fatal("error")
409+
}
410+
}

0 commit comments

Comments
 (0)