| @@ 1170-1193 (lines=24) @@ | ||
| 1167 | // We are aiming at the format: |
|
| 1168 | // [{text: 'optgroup text', children: [{id: '<sha>', text: '<inner text>'}]}] |
|
| 1169 | $redeploy = array(); |
|
| 1170 | foreach($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 1171 | $envName = $dnEnvironment->Name; |
|
| 1172 | $perEnvDeploys = array(); |
|
| 1173 | ||
| 1174 | foreach($dnEnvironment->DeployHistory() as $deploy) { |
|
| 1175 | $sha = $deploy->SHA; |
|
| 1176 | ||
| 1177 | // Check if exists to make sure the newest deployment date is used. |
|
| 1178 | if(!isset($perEnvDeploys[$sha])) { |
|
| 1179 | $pastValue = sprintf("%s (deployed %s)", |
|
| 1180 | substr($sha, 0, 8), |
|
| 1181 | $deploy->obj('LastEdited')->Ago() |
|
| 1182 | ); |
|
| 1183 | $perEnvDeploys[$sha] = array( |
|
| 1184 | 'id' => $sha, |
|
| 1185 | 'text' => $pastValue |
|
| 1186 | ); |
|
| 1187 | } |
|
| 1188 | } |
|
| 1189 | ||
| 1190 | if(!empty($perEnvDeploys)) { |
|
| 1191 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
| 1192 | } |
|
| 1193 | } |
|
| 1194 | // Convert the array to the frontend format (i.e. keyed to regular array) |
|
| 1195 | foreach($redeploy as $env => $descr) { |
|
| 1196 | $data['field_data'][] = array('text'=>$env, 'children'=>$descr); |
|
| @@ 164-186 (lines=23) @@ | ||
| 161 | */ |
|
| 162 | protected function getGitPrevDeploys($project) { |
|
| 163 | $redeploy = []; |
|
| 164 | foreach($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 165 | $envName = $dnEnvironment->Name; |
|
| 166 | $perEnvDeploys = []; |
|
| 167 | foreach($dnEnvironment->DeployHistory() as $deploy) { |
|
| 168 | $sha = $deploy->SHA; |
|
| 169 | ||
| 170 | // Check if exists to make sure the newest deployment date is used. |
|
| 171 | if(!isset($perEnvDeploys[$sha])) { |
|
| 172 | $pastValue = sprintf( |
|
| 173 | "%s (deployed %s)", |
|
| 174 | substr($sha, 0, 8), |
|
| 175 | $deploy->obj('LastEdited')->Ago() |
|
| 176 | ); |
|
| 177 | $perEnvDeploys[$sha] = [ |
|
| 178 | 'key' => $sha, |
|
| 179 | 'value' => $pastValue |
|
| 180 | ]; |
|
| 181 | } |
|
| 182 | } |
|
| 183 | if(!empty($perEnvDeploys)) { |
|
| 184 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
| 185 | } |
|
| 186 | } |
|
| 187 | return $redeploy; |
|
| 188 | } |
|
| 189 | } |
|