| @@ 1175-1198 (lines=24) @@ | ||
| 1172 | // We are aiming at the format: |
|
| 1173 | // [{text: 'optgroup text', children: [{id: '<sha>', text: '<inner text>'}]}] |
|
| 1174 | $redeploy = array(); |
|
| 1175 | foreach($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 1176 | $envName = $dnEnvironment->Name; |
|
| 1177 | $perEnvDeploys = array(); |
|
| 1178 | ||
| 1179 | foreach($dnEnvironment->DeployHistory() as $deploy) { |
|
| 1180 | $sha = $deploy->SHA; |
|
| 1181 | ||
| 1182 | // Check if exists to make sure the newest deployment date is used. |
|
| 1183 | if(!isset($perEnvDeploys[$sha])) { |
|
| 1184 | $pastValue = sprintf("%s (deployed %s)", |
|
| 1185 | substr($sha, 0, 8), |
|
| 1186 | $deploy->obj('LastEdited')->Ago() |
|
| 1187 | ); |
|
| 1188 | $perEnvDeploys[$sha] = array( |
|
| 1189 | 'id' => $sha, |
|
| 1190 | 'text' => $pastValue |
|
| 1191 | ); |
|
| 1192 | } |
|
| 1193 | } |
|
| 1194 | ||
| 1195 | if(!empty($perEnvDeploys)) { |
|
| 1196 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
| 1197 | } |
|
| 1198 | } |
|
| 1199 | // Convert the array to the frontend format (i.e. keyed to regular array) |
|
| 1200 | foreach($redeploy as $name => $descr) { |
|
| 1201 | $data['field_data'][] = array('text'=>$name, 'children'=>$descr); |
|
| @@ 208-230 (lines=23) @@ | ||
| 205 | */ |
|
| 206 | protected function getGitPrevDeploys($project) { |
|
| 207 | $redeploy = []; |
|
| 208 | foreach($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 209 | $envName = $dnEnvironment->Name; |
|
| 210 | $perEnvDeploys = []; |
|
| 211 | foreach($dnEnvironment->DeployHistory() as $deploy) { |
|
| 212 | $sha = $deploy->SHA; |
|
| 213 | ||
| 214 | // Check if exists to make sure the newest deployment date is used. |
|
| 215 | if(!isset($perEnvDeploys[$sha])) { |
|
| 216 | $pastValue = sprintf( |
|
| 217 | "%s (deployed %s)", |
|
| 218 | substr($sha, 0, 8), |
|
| 219 | $deploy->obj('LastEdited')->Ago() |
|
| 220 | ); |
|
| 221 | $perEnvDeploys[$sha] = [ |
|
| 222 | 'key' => $sha, |
|
| 223 | 'value' => $pastValue |
|
| 224 | ]; |
|
| 225 | } |
|
| 226 | } |
|
| 227 | if(!empty($perEnvDeploys)) { |
|
| 228 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
| 229 | } |
|
| 230 | } |
|
| 231 | return $redeploy; |
|
| 232 | } |
|
| 233 | ||