| @@ 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); |
|
| @@ 254-276 (lines=23) @@ | ||
| 251 | */ |
|
| 252 | protected function getGitPrevDeploys($project) { |
|
| 253 | $redeploy = []; |
|
| 254 | foreach($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 255 | $envName = $dnEnvironment->Name; |
|
| 256 | $perEnvDeploys = []; |
|
| 257 | foreach($dnEnvironment->DeployHistory() as $deploy) { |
|
| 258 | $sha = $deploy->SHA; |
|
| 259 | ||
| 260 | // Check if exists to make sure the newest deployment date is used. |
|
| 261 | if(!isset($perEnvDeploys[$sha])) { |
|
| 262 | $pastValue = sprintf( |
|
| 263 | "%s (deployed %s)", |
|
| 264 | substr($sha, 0, 8), |
|
| 265 | $deploy->obj('LastEdited')->Ago() |
|
| 266 | ); |
|
| 267 | $perEnvDeploys[$sha] = [ |
|
| 268 | 'key' => $sha, |
|
| 269 | 'value' => $pastValue |
|
| 270 | ]; |
|
| 271 | } |
|
| 272 | } |
|
| 273 | if(!empty($perEnvDeploys)) { |
|
| 274 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
| 275 | } |
|
| 276 | } |
|
| 277 | return $redeploy; |
|
| 278 | } |
|
| 279 | ||