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