| @@ 277-299 (lines=23) @@ | ||
| 274 | */ |
|
| 275 | protected function getGitPrevDeploys($project) { |
|
| 276 | $redeploy = []; |
|
| 277 | foreach ($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 278 | $envName = $dnEnvironment->Name; |
|
| 279 | $perEnvDeploys = []; |
|
| 280 | foreach ($dnEnvironment->DeployHistory()->filter('State', \DNDeployment::STATE_COMPLETED) as $deploy) { |
|
| 281 | $sha = $deploy->SHA; |
|
| 282 | ||
| 283 | // Check if exists to make sure the newest deployment date is used. |
|
| 284 | if (!isset($perEnvDeploys[$sha])) { |
|
| 285 | $pastValue = sprintf( |
|
| 286 | "%s (deployed %s)", |
|
| 287 | substr($sha, 0, 8), |
|
| 288 | $deploy->obj('LastEdited')->Ago() |
|
| 289 | ); |
|
| 290 | $perEnvDeploys[$sha] = [ |
|
| 291 | 'id' => $sha, |
|
| 292 | 'title' => $pastValue |
|
| 293 | ]; |
|
| 294 | } |
|
| 295 | } |
|
| 296 | if (!empty($perEnvDeploys)) { |
|
| 297 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
| 298 | } |
|
| 299 | } |
|
| 300 | return $redeploy; |
|
| 301 | } |
|
| 302 | ||
| @@ 1139-1162 (lines=24) @@ | ||
| 1136 | // We are aiming at the format: |
|
| 1137 | // [{text: 'optgroup text', children: [{id: '<sha>', text: '<inner text>'}]}] |
|
| 1138 | $redeploy = []; |
|
| 1139 | foreach ($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 1140 | $envName = $dnEnvironment->Name; |
|
| 1141 | $perEnvDeploys = []; |
|
| 1142 | ||
| 1143 | foreach ($dnEnvironment->DeployHistory()->filter('State', \DNDeployment::STATE_COMPLETED) as $deploy) { |
|
| 1144 | $sha = $deploy->SHA; |
|
| 1145 | ||
| 1146 | // Check if exists to make sure the newest deployment date is used. |
|
| 1147 | if (!isset($perEnvDeploys[$sha])) { |
|
| 1148 | $pastValue = sprintf("%s (deployed %s)", |
|
| 1149 | substr($sha, 0, 8), |
|
| 1150 | $deploy->obj('LastEdited')->Ago() |
|
| 1151 | ); |
|
| 1152 | $perEnvDeploys[$sha] = [ |
|
| 1153 | 'id' => $sha, |
|
| 1154 | 'text' => $pastValue |
|
| 1155 | ]; |
|
| 1156 | } |
|
| 1157 | } |
|
| 1158 | ||
| 1159 | if (!empty($perEnvDeploys)) { |
|
| 1160 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
| 1161 | } |
|
| 1162 | } |
|
| 1163 | // Convert the array to the frontend format (i.e. keyed to regular array) |
|
| 1164 | foreach ($redeploy as $name => $descr) { |
|
| 1165 | $data['field_data'][] = ['text' => $name, 'children' => $descr]; |
|