| @@ 1181-1204 (lines=24) @@ | ||
| 1178 | // We are aiming at the format: |
|
| 1179 | // [{text: 'optgroup text', children: [{id: '<sha>', text: '<inner text>'}]}] |
|
| 1180 | $redeploy = []; |
|
| 1181 | foreach ($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 1182 | $envName = $dnEnvironment->Name; |
|
| 1183 | $perEnvDeploys = []; |
|
| 1184 | ||
| 1185 | foreach ($dnEnvironment->DeployHistory() as $deploy) { |
|
| 1186 | $sha = $deploy->SHA; |
|
| 1187 | ||
| 1188 | // Check if exists to make sure the newest deployment date is used. |
|
| 1189 | if (!isset($perEnvDeploys[$sha])) { |
|
| 1190 | $pastValue = sprintf("%s (deployed %s)", |
|
| 1191 | substr($sha, 0, 8), |
|
| 1192 | $deploy->obj('LastEdited')->Ago() |
|
| 1193 | ); |
|
| 1194 | $perEnvDeploys[$sha] = [ |
|
| 1195 | 'id' => $sha, |
|
| 1196 | 'text' => $pastValue |
|
| 1197 | ]; |
|
| 1198 | } |
|
| 1199 | } |
|
| 1200 | ||
| 1201 | if (!empty($perEnvDeploys)) { |
|
| 1202 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
| 1203 | } |
|
| 1204 | } |
|
| 1205 | // Convert the array to the frontend format (i.e. keyed to regular array) |
|
| 1206 | foreach ($redeploy as $name => $descr) { |
|
| 1207 | $data['field_data'][] = ['text' => $name, 'children' => $descr]; |
|
| @@ 288-310 (lines=23) @@ | ||
| 285 | */ |
|
| 286 | protected function getGitPrevDeploys($project) { |
|
| 287 | $redeploy = []; |
|
| 288 | foreach ($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 289 | $envName = $dnEnvironment->Name; |
|
| 290 | $perEnvDeploys = []; |
|
| 291 | foreach ($dnEnvironment->DeployHistory() as $deploy) { |
|
| 292 | $sha = $deploy->SHA; |
|
| 293 | ||
| 294 | // Check if exists to make sure the newest deployment date is used. |
|
| 295 | if (!isset($perEnvDeploys[$sha])) { |
|
| 296 | $pastValue = sprintf( |
|
| 297 | "%s (deployed %s)", |
|
| 298 | substr($sha, 0, 8), |
|
| 299 | $deploy->obj('LastEdited')->Ago() |
|
| 300 | ); |
|
| 301 | $perEnvDeploys[$sha] = [ |
|
| 302 | 'id' => $sha, |
|
| 303 | 'title' => $pastValue |
|
| 304 | ]; |
|
| 305 | } |
|
| 306 | } |
|
| 307 | if (!empty($perEnvDeploys)) { |
|
| 308 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
| 309 | } |
|
| 310 | } |
|
| 311 | return $redeploy; |
|
| 312 | } |
|
| 313 | ||