Permalink
Browse files

Clean up warnings in Health view

  • Loading branch information...
flodolo committed Dec 30, 2015
1 parent a4798ab commit 17b9504f49a2c71d50dff9c6cdc2d778c0d7d11d
Showing with 60 additions and 40 deletions.
  1. +44 −39 app/models/health_status.php
  2. +16 −1 app/views/health_status.php
@@ -6,6 +6,7 @@
use VCS\Mercurial;
use VCS\Subversion;
$projects = [];
foreach (Project::getRepositories() as $repo) {
// Get the right locale for this repo
@@ -243,45 +244,7 @@ function ($entity) use ($path) {
}
}
// Get stats
$stats = Health::getStats($projects);
$translated = $stats['translated'];
$reference = $stats['total'];
$completion = round(($translated / $reference) * 100, 2);
$completion = $completion > 100 ? 100 : $completion;
// Get color from completion value
$color = Utils::redYellowGreen($completion);
// Get active projects
$active_projects = '<h4>Active projects:</h4><ul>';
if (isset($projects['release']['repos'])) {
$active_projects .= '<li><b>Desktop:</b> ';
foreach (array_keys($projects['release']['repos']) as $repo) {
if (in_array($repo, array_keys(Project::$components_names))) {
$active_projects .= Project::$components_names[$repo] . ', ';
}
}
$active_projects .= '</li>';
}
if (isset($projects['gaia'])) {
$active_projects .= '<li><b>Gaia:</b> ';
foreach (array_keys($projects['gaia']) as $repo) {
$active_projects .= Project::getRepositoriesNames()[$repo] . ', ';
}
$active_projects .= '</li>';
}
if (isset($projects['others'])) {
$active_projects .= '<li><b>Others:</b> ';
foreach (array_keys($projects['others']) as $repo) {
$active_projects .= Project::getRepositoriesNames()[$repo] . ', ';
}
$active_projects .= '</li>';
}
$active_projects .= '</ul>';
$active_projects = '';
// Build locales select
$target_locales_list = '';
@@ -292,3 +255,45 @@ function ($entity) use ($path) {
$ch = ($loc == $locale) ? ' selected' : '';
$target_locales_list .= "\t<option{$ch} value={$loc}>{$loc}</option>\n";
}
// Get stats
if (! empty($projects)) {
$stats = Health::getStats($projects);
$translated = $stats['translated'];
$reference = $stats['total'];
$completion = round(($translated / $reference) * 100, 2);
$completion = $completion > 100 ? 100 : $completion;
// Get color from completion value
$color = Utils::redYellowGreen($completion);
// Get active projects
if (isset($projects['release']['repos'])) {
$active_projects .= '<li><b>Desktop:</b> ';
$tmp_projects = [];
foreach (array_keys($projects['release']['repos']) as $repo) {
if (in_array($repo, array_keys(Project::$components_names))) {
$tmp_projects[] = Project::$components_names[$repo];
}
}
$active_projects .= implode(', ', $tmp_projects) . '</li>';
}
if (isset($projects['gaia'])) {
$active_projects .= '<li><b>Gaia:</b> ';
$tmp_projects = [];
foreach (array_keys($projects['gaia']) as $repo) {
$tmp_projects[] = Project::getRepositoriesNames()[$repo];
}
$active_projects .= implode(', ', $tmp_projects) . '</li>';
}
if (isset($projects['others'])) {
$active_projects .= '<li><b>Others:</b> ';
$tmp_projects = [];
foreach (array_keys($projects['others']) as $repo) {
$tmp_projects[] = Project::getRepositoriesNames()[$repo];
}
$active_projects .= implode(', ', $tmp_projects) . '</li>';
}
}
@@ -12,8 +12,20 @@
<h3>Health Status for <?=$page_locale?></h3>
<div id="wrapper">
<?php
if (empty($active_projects)):
?>
<div class="metrics">
<?=$active_projects?>
<p>The requested locale doesn't have any supported project.</p>
</div>
<?php
else:
?>
<div class="metrics">
<h4>Active projects:</h4>
<ul>
<?=$active_projects?>
</ul>
<h4>General metrics:</h4>
<ul>
<li class="metric">Global completion: <span class="completion" style="background-color:rgb(<?=$color?>)">~<?=$completion?>%</span></li>
@@ -29,4 +41,7 @@
<?=$content?>
</div>
</div>
<?php
endif;
?>
</div>

0 comments on commit 17b9504

Please sign in to comment.