@@ 272-294 (lines=23) @@ | ||
269 | */ |
|
270 | protected function getGitPrevDeploys($project) { |
|
271 | $redeploy = []; |
|
272 | foreach ($project->DNEnvironmentList() as $dnEnvironment) { |
|
273 | $envName = $dnEnvironment->Name; |
|
274 | $perEnvDeploys = []; |
|
275 | foreach ($dnEnvironment->DeployHistory() as $deploy) { |
|
276 | $sha = $deploy->SHA; |
|
277 | ||
278 | // Check if exists to make sure the newest deployment date is used. |
|
279 | if (!isset($perEnvDeploys[$sha])) { |
|
280 | $pastValue = sprintf( |
|
281 | "%s (deployed %s)", |
|
282 | substr($sha, 0, 8), |
|
283 | $deploy->obj('LastEdited')->Ago() |
|
284 | ); |
|
285 | $perEnvDeploys[$sha] = [ |
|
286 | 'id' => $sha, |
|
287 | 'title' => $pastValue |
|
288 | ]; |
|
289 | } |
|
290 | } |
|
291 | if (!empty($perEnvDeploys)) { |
|
292 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
293 | } |
|
294 | } |
|
295 | return $redeploy; |
|
296 | } |
|
297 |
@@ 1136-1159 (lines=24) @@ | ||
1133 | // We are aiming at the format: |
|
1134 | // [{text: 'optgroup text', children: [{id: '<sha>', text: '<inner text>'}]}] |
|
1135 | $redeploy = []; |
|
1136 | foreach ($project->DNEnvironmentList() as $dnEnvironment) { |
|
1137 | $envName = $dnEnvironment->Name; |
|
1138 | $perEnvDeploys = []; |
|
1139 | ||
1140 | foreach ($dnEnvironment->DeployHistory() as $deploy) { |
|
1141 | $sha = $deploy->SHA; |
|
1142 | ||
1143 | // Check if exists to make sure the newest deployment date is used. |
|
1144 | if (!isset($perEnvDeploys[$sha])) { |
|
1145 | $pastValue = sprintf("%s (deployed %s)", |
|
1146 | substr($sha, 0, 8), |
|
1147 | $deploy->obj('LastEdited')->Ago() |
|
1148 | ); |
|
1149 | $perEnvDeploys[$sha] = [ |
|
1150 | 'id' => $sha, |
|
1151 | 'text' => $pastValue |
|
1152 | ]; |
|
1153 | } |
|
1154 | } |
|
1155 | ||
1156 | if (!empty($perEnvDeploys)) { |
|
1157 | $redeploy[$envName] = array_values($perEnvDeploys); |
|
1158 | } |
|
1159 | } |
|
1160 | // Convert the array to the frontend format (i.e. keyed to regular array) |
|
1161 | foreach ($redeploy as $name => $descr) { |
|
1162 | $data['field_data'][] = ['text' => $name, 'children' => $descr]; |