Skip to content

Commit

Permalink
#30 add // QUEUED pipeline steps status queued
Browse files Browse the repository at this point in the history
  • Loading branch information
zeromsi committed Aug 21, 2022
1 parent 01d6b62 commit 3220f0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion core/v1/logic/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func GetProcessStatusMapFromEvents(events []v1.ProcessLifeCycleEvent) map[string
if each.Status == enums.FAILED {
processStatusMap[each.ProcessId] = each.Status
} else if val != enums.FAILED {
if val == enums.PAUSED && each.Status == enums.ACTIVE {
if val == enums.QUEUED && each.Status == enums.ACTIVE {
processStatusMap[each.ProcessId] = enums.ACTIVE
} else if val == enums.COMPLETED && (each.Status == enums.NON_INITIALIZED || each.Status == enums.QUEUED) {
processStatusMap[each.ProcessId] = enums.PAUSED
Expand Down
28 changes: 9 additions & 19 deletions repository/v1/mongo/process_life_cycle_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,13 @@ func (p processLifeCycleRepository) UpdateClaim(companyId, processId, step, stat

func (p processLifeCycleRepository) PullNonInitializedAndAutoTriggerEnabledEventsByStepType(count int64, stepType string) []v1.ProcessLifeCycleEvent {
var data []v1.ProcessLifeCycleEvent
var query bson.M
if stepType == string(enums.BUILD) {
query = bson.M{
"$and": []bson.M{
{"status": enums.QUEUED},
{"trigger": enums.AUTO},
{"step_type": stepType},
},
}
} else {
query = bson.M{
"$and": []bson.M{
{"status": enums.PAUSED},
{"trigger": enums.AUTO},
{"step_type": stepType},
},
}

query := bson.M{
"$and": []bson.M{
{"status": enums.QUEUED},
{"trigger": enums.AUTO},
{"step_type": stepType},
},
}

coll := p.manager.Db.Collection(ProcessLifeCycleCollection)
Expand Down Expand Up @@ -174,7 +164,7 @@ func (p processLifeCycleRepository) PullPausedAndAutoTriggerEnabledResourcesByAg
query := bson.M{
"$and": []bson.M{
{"agent": agent},
{"status": enums.PAUSED},
{"status": enums.QUEUED},
{"trigger": enums.AUTO},
{"step_type": enums.DEPLOY},
},
Expand Down Expand Up @@ -243,7 +233,7 @@ func (p processLifeCycleRepository) Store(events []v1.ProcessLifeCycleEvent) {
log.Println(err.Error())
}
} else {
if each.Status == enums.PAUSED {
if each.Status == enums.QUEUED {
existing.Claim = existing.Claim + 1
}
existing.ClaimedAt = time.Now().UTC()
Expand Down

0 comments on commit 3220f0c

Please sign in to comment.