| @@ 278-300 (lines=23) @@ | ||
| 275 | */ |
|
| 276 | protected function getGitPrevDeploys($project) { |
|
| 277 | $redeploy = []; |
|
| 278 | foreach ($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 279 | $envName = $dnEnvironment->Name; |
|
| 280 | $perEnvDeploys = []; |
|
| 281 | foreach ($dnEnvironment->DeployHistory()->filter('State', \DNDeployment::STATE_COMPLETED) as $deploy) { |
|
| 282 | $sha = $deploy->SHA; |
|
| 283 | ||
| 284 | // Check if exists to make sure the newest deployment date is used. |
|
| 285 | if (!isset($perEnvDeploys[$sha])) { |
|
| 286 | $pastValue = sprintf( |
|
| 287 | "%s (deployed %s)", |
|
| 288 | substr($sha, 0, 8), |
|
| 289 | $deploy->obj('LastEdited')->Ago() |
|
| 290 | ); |
|
| 291 | $perEnvDeploys[$sha] = [ |
|
| 292 | 'id' => $sha, |
|
| 293 | 'title' => $pastValue |
|
| 294 | ]; |
|
| 295 | } |
|
| 296 | } |
|
| 297 | if (!empty($perEnvDeploys)) { |
|
| 298 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
| 299 | } |
|
| 300 | } |
|
| 301 | return $redeploy; |
|
| 302 | } |
|
| 303 | ||
| @@ 1167-1190 (lines=24) @@ | ||
| 1164 | // We are aiming at the format: |
|
| 1165 | // [{text: 'optgroup text', children: [{id: '<sha>', text: '<inner text>'}]}] |
|
| 1166 | $redeploy = []; |
|
| 1167 | foreach ($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 1168 | $envName = $dnEnvironment->Name; |
|
| 1169 | $perEnvDeploys = []; |
|
| 1170 | ||
| 1171 | foreach ($dnEnvironment->DeployHistory()->filter('State', \DNDeployment::STATE_COMPLETED) as $deploy) { |
|
| 1172 | $sha = $deploy->SHA; |
|
| 1173 | ||
| 1174 | // Check if exists to make sure the newest deployment date is used. |
|
| 1175 | if (!isset($perEnvDeploys[$sha])) { |
|
| 1176 | $pastValue = sprintf("%s (deployed %s)", |
|
| 1177 | substr($sha, 0, 8), |
|
| 1178 | $deploy->obj('LastEdited')->Ago() |
|
| 1179 | ); |
|
| 1180 | $perEnvDeploys[$sha] = [ |
|
| 1181 | 'id' => $sha, |
|
| 1182 | 'text' => $pastValue |
|
| 1183 | ]; |
|
| 1184 | } |
|
| 1185 | } |
|
| 1186 | ||
| 1187 | if (!empty($perEnvDeploys)) { |
|
| 1188 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
| 1189 | } |
|
| 1190 | } |
|
| 1191 | // Convert the array to the frontend format (i.e. keyed to regular array) |
|
| 1192 | foreach ($redeploy as $name => $descr) { |
|
| 1193 | $data['field_data'][] = ['text' => $name, 'children' => $descr]; |
|