| @@ 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 | ||
| @@ 1158-1181 (lines=24) @@ | ||
| 1155 | // We are aiming at the format: |
|
| 1156 | // [{text: 'optgroup text', children: [{id: '<sha>', text: '<inner text>'}]}] |
|
| 1157 | $redeploy = []; |
|
| 1158 | foreach ($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 1159 | $envName = $dnEnvironment->Name; |
|
| 1160 | $perEnvDeploys = []; |
|
| 1161 | ||
| 1162 | foreach ($dnEnvironment->DeployHistory() as $deploy) { |
|
| 1163 | $sha = $deploy->SHA; |
|
| 1164 | ||
| 1165 | // Check if exists to make sure the newest deployment date is used. |
|
| 1166 | if (!isset($perEnvDeploys[$sha])) { |
|
| 1167 | $pastValue = sprintf("%s (deployed %s)", |
|
| 1168 | substr($sha, 0, 8), |
|
| 1169 | $deploy->obj('LastEdited')->Ago() |
|
| 1170 | ); |
|
| 1171 | $perEnvDeploys[$sha] = [ |
|
| 1172 | 'id' => $sha, |
|
| 1173 | 'text' => $pastValue |
|
| 1174 | ]; |
|
| 1175 | } |
|
| 1176 | } |
|
| 1177 | ||
| 1178 | if (!empty($perEnvDeploys)) { |
|
| 1179 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
| 1180 | } |
|
| 1181 | } |
|
| 1182 | // Convert the array to the frontend format (i.e. keyed to regular array) |
|
| 1183 | foreach ($redeploy as $name => $descr) { |
|
| 1184 | $data['field_data'][] = ['text' => $name, 'children' => $descr]; |
|