Skip to content

Commit

Permalink
Clean up warnings in Health view
Browse files Browse the repository at this point in the history
  • Loading branch information
flodolo committed Dec 30, 2015
1 parent a4798ab commit 17b9504
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 40 deletions.
83 changes: 44 additions & 39 deletions app/models/health_status.php
Expand Up @@ -6,6 +6,7 @@
use VCS\Mercurial;
use VCS\Subversion;

$projects = [];
foreach (Project::getRepositories() as $repo) {

// Get the right locale for this repo
Expand Down Expand Up @@ -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 = '';
Expand All @@ -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>';
}
}
17 changes: 16 additions & 1 deletion app/views/health_status.php
Expand Up @@ -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>
Expand All @@ -29,4 +41,7 @@
<?=$content?>
</div>
</div>
<?php
endif;
?>
</div>

0 comments on commit 17b9504

Please sign in to comment.