From 17b9504f49a2c71d50dff9c6cdc2d778c0d7d11d Mon Sep 17 00:00:00 2001 From: "Francesco Lodolo (:flod)" Date: Wed, 30 Dec 2015 09:23:17 +0100 Subject: [PATCH] Clean up warnings in Health view --- app/models/health_status.php | 83 +++++++++++++++++++----------------- app/views/health_status.php | 17 +++++++- 2 files changed, 60 insertions(+), 40 deletions(-) diff --git a/app/models/health_status.php b/app/models/health_status.php index 2d53f262..ee0a1471 100644 --- a/app/models/health_status.php +++ b/app/models/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 = '

Active projects:

'; +$active_projects = ''; // Build locales select $target_locales_list = ''; @@ -292,3 +255,45 @@ function ($entity) use ($path) { $ch = ($loc == $locale) ? ' selected' : ''; $target_locales_list .= "\t{$loc}\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 .= '
  • Desktop: '; + $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) . '
  • '; + } + + if (isset($projects['gaia'])) { + $active_projects .= '
  • Gaia: '; + $tmp_projects = []; + foreach (array_keys($projects['gaia']) as $repo) { + $tmp_projects[] = Project::getRepositoriesNames()[$repo]; + } + $active_projects .= implode(', ', $tmp_projects) . '
  • '; + } + + if (isset($projects['others'])) { + $active_projects .= '
  • Others: '; + $tmp_projects = []; + foreach (array_keys($projects['others']) as $repo) { + $tmp_projects[] = Project::getRepositoriesNames()[$repo]; + } + $active_projects .= implode(', ', $tmp_projects) . '
  • '; + } +} diff --git a/app/views/health_status.php b/app/views/health_status.php index 5649942f..c763172e 100644 --- a/app/views/health_status.php +++ b/app/views/health_status.php @@ -12,8 +12,20 @@

    Health Status for

    +
    - +

    The requested locale doesn't have any supported project.

    +
    + +
    +

    Active projects:

    +
      + +

    General metrics:

    • Global completion: ~%
    • @@ -29,4 +41,7 @@
    +