Skip to content

Commit 17b9504

Browse files
committed
Clean up warnings in Health view
1 parent a4798ab commit 17b9504

File tree

2 files changed

+60
-40
lines changed

2 files changed

+60
-40
lines changed

app/models/health_status.php

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use VCS\Mercurial;
77
use VCS\Subversion;
88

9+
$projects = [];
910
foreach (Project::getRepositories() as $repo) {
1011

1112
// Get the right locale for this repo
@@ -243,45 +244,7 @@ function ($entity) use ($path) {
243244
}
244245
}
245246

246-
// Get stats
247-
$stats = Health::getStats($projects);
248-
$translated = $stats['translated'];
249-
$reference = $stats['total'];
250-
251-
$completion = round(($translated / $reference) * 100, 2);
252-
$completion = $completion > 100 ? 100 : $completion;
253-
254-
// Get color from completion value
255-
$color = Utils::redYellowGreen($completion);
256-
257-
// Get active projects
258-
$active_projects = '<h4>Active projects:</h4><ul>';
259-
if (isset($projects['release']['repos'])) {
260-
$active_projects .= '<li><b>Desktop:</b> ';
261-
foreach (array_keys($projects['release']['repos']) as $repo) {
262-
if (in_array($repo, array_keys(Project::$components_names))) {
263-
$active_projects .= Project::$components_names[$repo] . ', ';
264-
}
265-
}
266-
$active_projects .= '</li>';
267-
}
268-
269-
if (isset($projects['gaia'])) {
270-
$active_projects .= '<li><b>Gaia:</b> ';
271-
foreach (array_keys($projects['gaia']) as $repo) {
272-
$active_projects .= Project::getRepositoriesNames()[$repo] . ', ';
273-
}
274-
$active_projects .= '</li>';
275-
}
276-
277-
if (isset($projects['others'])) {
278-
$active_projects .= '<li><b>Others:</b> ';
279-
foreach (array_keys($projects['others']) as $repo) {
280-
$active_projects .= Project::getRepositoriesNames()[$repo] . ', ';
281-
}
282-
$active_projects .= '</li>';
283-
}
284-
$active_projects .= '</ul>';
247+
$active_projects = '';
285248

286249
// Build locales select
287250
$target_locales_list = '';
@@ -292,3 +255,45 @@ function ($entity) use ($path) {
292255
$ch = ($loc == $locale) ? ' selected' : '';
293256
$target_locales_list .= "\t<option{$ch} value={$loc}>{$loc}</option>\n";
294257
}
258+
259+
// Get stats
260+
if (! empty($projects)) {
261+
$stats = Health::getStats($projects);
262+
$translated = $stats['translated'];
263+
$reference = $stats['total'];
264+
$completion = round(($translated / $reference) * 100, 2);
265+
$completion = $completion > 100 ? 100 : $completion;
266+
267+
// Get color from completion value
268+
$color = Utils::redYellowGreen($completion);
269+
270+
// Get active projects
271+
if (isset($projects['release']['repos'])) {
272+
$active_projects .= '<li><b>Desktop:</b> ';
273+
$tmp_projects = [];
274+
foreach (array_keys($projects['release']['repos']) as $repo) {
275+
if (in_array($repo, array_keys(Project::$components_names))) {
276+
$tmp_projects[] = Project::$components_names[$repo];
277+
}
278+
}
279+
$active_projects .= implode(', ', $tmp_projects) . '</li>';
280+
}
281+
282+
if (isset($projects['gaia'])) {
283+
$active_projects .= '<li><b>Gaia:</b> ';
284+
$tmp_projects = [];
285+
foreach (array_keys($projects['gaia']) as $repo) {
286+
$tmp_projects[] = Project::getRepositoriesNames()[$repo];
287+
}
288+
$active_projects .= implode(', ', $tmp_projects) . '</li>';
289+
}
290+
291+
if (isset($projects['others'])) {
292+
$active_projects .= '<li><b>Others:</b> ';
293+
$tmp_projects = [];
294+
foreach (array_keys($projects['others']) as $repo) {
295+
$tmp_projects[] = Project::getRepositoriesNames()[$repo];
296+
}
297+
$active_projects .= implode(', ', $tmp_projects) . '</li>';
298+
}
299+
}

app/views/health_status.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,20 @@
1212

1313
<h3>Health Status for <?=$page_locale?></h3>
1414
<div id="wrapper">
15+
<?php
16+
if (empty($active_projects)):
17+
?>
1518
<div class="metrics">
16-
<?=$active_projects?>
19+
<p>The requested locale doesn't have any supported project.</p>
20+
</div>
21+
<?php
22+
else:
23+
?>
24+
<div class="metrics">
25+
<h4>Active projects:</h4>
26+
<ul>
27+
<?=$active_projects?>
28+
</ul>
1729
<h4>General metrics:</h4>
1830
<ul>
1931
<li class="metric">Global completion: <span class="completion" style="background-color:rgb(<?=$color?>)">~<?=$completion?>%</span></li>
@@ -29,4 +41,7 @@
2941
<?=$content?>
3042
</div>
3143
</div>
44+
<?php
45+
endif;
46+
?>
3247
</div>

0 commit comments

Comments
 (0)