Download this file
| 1 | import Foundation |
| 2 | |
| 3 | /// work_views.go pageTask: an exploration drops earlier merge attempts from |
| 4 | /// its presentation. The decoded wire task remains intact. |
| 5 | enum TaskPage { |
| 6 | // Wire steps are ordered oldest to newest, as on the web task timeline. |
| 7 | static func latestReview(_ task: ThinTask) -> ThinStep? { |
| 8 | guard !task.candidateSha.isEmpty else { return nil } |
| 9 | return task.steps?.last { $0.specialist == "review" && $0.candidateSha == task.candidateSha } |
| 10 | } |
| 11 | static func latestChecks(_ task: ThinTask) -> ThinStep? { |
| 12 | guard !task.candidateSha.isEmpty else { return nil } |
| 13 | return task.steps?.last { $0.specialist == "checks" && $0.candidateSha == task.candidateSha } |
| 14 | } |
| 15 | static func checksLogStep(_ task: ThinTask) -> ThinStep? { |
| 16 | guard let step = latestChecks(task), ["done", "failed"].contains(step.state) else { return nil } |
| 17 | return step |
| 18 | } |
| 19 | static func placementLead(_ task: ThinTask) -> String? { |
| 20 | guard task.moving == true || task.stopping == true else { return nil } |
| 21 | if task.stopping == true { return EquipoStrings.text("roster.stopping") } |
| 22 | if let reason = task.moveHoldReason, !reason.isEmpty { return Feed.webText("placement.held_" + reason) } |
| 23 | if task.preparingProject == true { return EquipoStrings.text("placement.preparing") } |
| 24 | return EquipoStrings.text("placement.pending") |
| 25 | } |
| 26 | static func task(_ task: ThinTask) -> ThinTask { |
| 27 | guard task.kind == "explore" else { return task } |
| 28 | var result = task |
| 29 | result.steps = task.steps?.filter { $0.specialist != "merge" } |
| 30 | return result |
| 31 | } |
| 32 | } |
| 33 | |