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