summaryrefslogtreecommitdiffstats
path: root/non-puppet/qtmetrics2
diff options
context:
space:
mode:
authorJuha Sippola <juhasippola@outlook.com>2015-09-21 15:45:11 +0300
committerTony Sarajärvi <tony.sarajarvi@theqtcompany.com>2015-09-23 09:38:38 +0000
commit7f9df253643ed49e3412383ee76fe7e321444aa0 (patch)
treea2df0b803647eef204f4314344d8722c66a41a8c /non-puppet/qtmetrics2
parent096b99cdfc4f6ee17a09aa09c77a650be4877e06 (diff)
Qt Metrics 2 (v0.24): Database refresh indication
Indicate the database update time and possible running database refresh (log parsing) operation in the header. Change-Id: Ic7a7f94bcf696eb62173b540f9e9e50b749a0585 Reviewed-by: Tony Sarajärvi <tony.sarajarvi@theqtcompany.com>
Diffstat (limited to 'non-puppet/qtmetrics2')
-rw-r--r--non-puppet/qtmetrics2/index.php61
-rw-r--r--non-puppet/qtmetrics2/scripts/reload.js43
-rw-r--r--non-puppet/qtmetrics2/src/Database.php30
-rw-r--r--non-puppet/qtmetrics2/src/test/DatabaseTest.php30
-rw-r--r--non-puppet/qtmetrics2/templates/about.html4
-rw-r--r--non-puppet/qtmetrics2/templates/footer.html6
-rw-r--r--non-puppet/qtmetrics2/templates/header.html18
7 files changed, 169 insertions, 23 deletions
diff --git a/non-puppet/qtmetrics2/index.php b/non-puppet/qtmetrics2/index.php
index 8cef994..02a232f 100644
--- a/non-puppet/qtmetrics2/index.php
+++ b/non-puppet/qtmetrics2/index.php
@@ -34,7 +34,7 @@
/**
* Qt Metrics API
- * @since 09-09-2015
+ * @since 15-09-2015
* @author Juha Sippola
*/
@@ -62,14 +62,16 @@ $app = new Slim\Slim(array(
$app->get('/', function() use($app)
{
$ini = Factory::conf();
+ $dbStatus = Factory::db()->getDbRefreshStatus();
$buildProjectPlatformRoute = str_replace('/:targetOs', '', Slim\Slim::getInstance()->urlFor('buildproject_platform'));
$app->render('home.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
+ 'refreshed' => $dbStatus['refreshed'] . ' (GMT)',
'overviewRoute' => Slim\Slim::getInstance()->urlFor('overview'),
'platformRoute' => $buildProjectPlatformRoute,
'topRoute' => Slim\Slim::getInstance()->urlFor('top'),
'flakyRoute' => Slim\Slim::getInstance()->urlFor('flaky'),
- 'refreshed' => Factory::db()->getDbRefreshed() . ' (GMT)',
'masterProject' => $ini['master_build_project'],
'masterState' => $ini['master_build_state'],
'branches' => Factory::db()->getBranches(),
@@ -84,6 +86,7 @@ $app->get('/', function() use($app)
$app->get('/overview', function() use($app)
{
$ini = Factory::conf();
+ $dbStatus = Factory::db()->getDbRefreshStatus();
$breadcrumb = array(
array('name' => 'home', 'link' => Slim\Slim::getInstance()->urlFor('root'))
);
@@ -91,10 +94,11 @@ $app->get('/overview', function() use($app)
$testsetProjectRoute = str_replace('/:project', '', Slim\Slim::getInstance()->urlFor('testsetproject'));
$app->render('overview.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
+ 'refreshed' => $dbStatus['refreshed'] . ' (GMT)',
'breadcrumb' => $breadcrumb,
'buildProjectRoute' => $buildProjectRoute,
'testsetProjectRoute' => $testsetProjectRoute,
- 'refreshed' => Factory::db()->getDbRefreshed() . ' (GMT)',
'masterProject' => $ini['master_build_project'],
'masterState' => $ini['master_build_state'],
'latestProjectRuns' => Factory::db()->getLatestProjectBranchBuildResults(
@@ -113,6 +117,7 @@ $app->get('/overview', function() use($app)
$app->get('/buildproject', function() use($app)
{
$ini = Factory::conf();
+ $dbStatus = Factory::db()->getDbRefreshStatus();
$breadcrumb = array(
array('name' => 'home', 'link' => Slim\Slim::getInstance()->urlFor('root')),
array('name' => 'overview', 'link' => Slim\Slim::getInstance()->urlFor('overview'))
@@ -121,10 +126,11 @@ $app->get('/buildproject', function() use($app)
$confRoute = str_replace('/:conf', '', Slim\Slim::getInstance()->urlFor('conf'));
$app->render('build_project.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
+ 'refreshed' => $dbStatus['refreshed'] . ' (GMT)',
'breadcrumb' => $breadcrumb,
'buildPlatformRoute' => $buildProjectPlatformRoute,
'confRoute' => $confRoute,
- 'refreshed' => Factory::db()->getDbRefreshed() . ' (GMT)',
'masterProject' => $ini['master_build_project'],
'masterState' => $ini['master_build_state'],
'platforms' => Factory::db()->getTargetPlatformOs(),
@@ -156,6 +162,7 @@ $app->get('/buildproject/platform/:targetOs', function($targetOs) use($app)
{
$targetOs = strip_tags($targetOs);
$ini = Factory::conf();
+ $dbStatus = Factory::db()->getDbRefreshStatus();
$buildProjectRoute = str_replace('/:project', '', Slim\Slim::getInstance()->urlFor('buildproject'));
$breadcrumb = array(
array('name' => 'home', 'link' => Slim\Slim::getInstance()->urlFor('root')),
@@ -166,10 +173,11 @@ $app->get('/buildproject/platform/:targetOs', function($targetOs) use($app)
$confRoute = str_replace('/:conf', '', Slim\Slim::getInstance()->urlFor('conf'));
$app->render('build_project.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
+ 'refreshed' => $dbStatus['refreshed'] . ' (GMT)',
'breadcrumb' => $breadcrumb,
'buildPlatformRoute' => $buildProjectPlatformRoute,
'confRoute' => $confRoute,
- 'refreshed' => Factory::db()->getDbRefreshed() . ' (GMT)',
'masterProject' => $ini['master_build_project'],
'masterState' => $ini['master_build_state'],
'platforms' => Factory::db()->getTargetPlatformOs(),
@@ -200,14 +208,16 @@ $app->get('/testsetproject/:project', function($project) use($app)
{
$project = strip_tags($project);
$ini = Factory::conf();
+ $dbStatus = Factory::db()->getDbRefreshStatus();
$breadcrumb = array(
array('name' => 'home', 'link' => Slim\Slim::getInstance()->urlFor('root')),
array('name' => 'overview', 'link' => Slim\Slim::getInstance()->urlFor('overview'))
);
$app->render('testset_project.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
+ 'refreshed' => $dbStatus['refreshed'] . ' (GMT)',
'breadcrumb' => $breadcrumb,
- 'refreshed' => Factory::db()->getDbRefreshed() . ' (GMT)',
'masterProject' => $ini['master_build_project'],
'masterState' => $ini['master_build_state'],
'project' => $project
@@ -253,6 +263,7 @@ $app->get('/conf/:conf', function($conf) use($app)
{
$conf = strip_tags($conf);
$ini = Factory::conf();
+ $dbStatus = Factory::db()->getDbRefreshStatus();
$buildProjectRoute = str_replace('/:project', '', Slim\Slim::getInstance()->urlFor('buildproject'));
$breadcrumb = array(
array('name' => 'home', 'link' => Slim\Slim::getInstance()->urlFor('root')),
@@ -263,10 +274,11 @@ $app->get('/conf/:conf', function($conf) use($app)
$testsetProjectRoute = str_replace('/:project', '', Slim\Slim::getInstance()->urlFor('testsetproject'));
$app->render('conf.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
+ 'refreshed' => $dbStatus['refreshed'] . ' (GMT)',
'breadcrumb' => $breadcrumb,
'testsetTestfunctionsRoute' => $testsetTestfunctionsRoute,
'testsetProjectRoute' => $testsetProjectRoute,
- 'refreshed' => Factory::db()->getDbRefreshed() . ' (GMT)',
'masterProject' => $ini['master_build_project'],
'masterState' => $ini['master_build_state'],
'testsetProject' => '',
@@ -303,6 +315,7 @@ $app->get('/conf/:conf/:testsetproject', function($conf, $testsetProject) use($a
$conf = strip_tags($conf);
$testsetProject = strip_tags($testsetProject);
$ini = Factory::conf();
+ $dbStatus = Factory::db()->getDbRefreshStatus();
$testsetProjectRoute = str_replace('/:project', '', Slim\Slim::getInstance()->urlFor('testsetproject'));
$breadcrumb = array(
array('name' => 'home', 'link' => Slim\Slim::getInstance()->urlFor('root')),
@@ -312,10 +325,11 @@ $app->get('/conf/:conf/:testsetproject', function($conf, $testsetProject) use($a
$testsetTestfunctionsRoute = str_replace('/:testset/:project/:conf', '', Slim\Slim::getInstance()->urlFor('testset_testfunctions'));
$app->render('conf.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
+ 'refreshed' => $dbStatus['refreshed'] . ' (GMT)',
'breadcrumb' => $breadcrumb,
'testsetTestfunctionsRoute' => $testsetTestfunctionsRoute,
'testsetProjectRoute' => $testsetProjectRoute,
- 'refreshed' => Factory::db()->getDbRefreshed() . ' (GMT)',
'masterProject' => $ini['master_build_project'],
'masterState' => $ini['master_build_state'],
'testsetProject' => $testsetProject,
@@ -347,6 +361,7 @@ $app->get('/conf/:conf/:testsetproject', function($conf, $testsetProject) use($a
$app->get('/test/top', function() use($app)
{
$ini = Factory::conf();
+ $dbStatus = Factory::db()->getDbRefreshStatus();
$days = intval($ini['top_failures_last_days']) - 1;
$since = Factory::getSinceDate($days);
$breadcrumb = array(
@@ -354,8 +369,9 @@ $app->get('/test/top', function() use($app)
);
$app->render('testsets_top.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
+ 'refreshed' => $dbStatus['refreshed'] . ' (GMT)',
'breadcrumb' => $breadcrumb,
- 'refreshed' => Factory::db()->getDbRefreshed() . ' (GMT)',
'topN' => $ini['top_failures_n'],
'lastDays' => $ini['top_failures_last_days'],
'sinceDate' => $since,
@@ -387,6 +403,7 @@ $app->get('/data/test/top', function() use($app)
$app->get('/test/flaky', function() use($app)
{
$ini = Factory::conf();
+ $dbStatus = Factory::db()->getDbRefreshStatus();
$days = intval($ini['flaky_testsets_last_days']) - 1;
$since = Factory::getSinceDate($days);
$breadcrumb = array(
@@ -394,8 +411,9 @@ $app->get('/test/flaky', function() use($app)
);
$app->render('testsets_flaky.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
+ 'refreshed' => $dbStatus['refreshed'] . ' (GMT)',
'breadcrumb' => $breadcrumb,
- 'refreshed' => Factory::db()->getDbRefreshed() . ' (GMT)',
'topN' => $ini['flaky_testsets_n'],
'lastDays' => $ini['flaky_testsets_last_days'],
'sinceDate' => $since
@@ -426,6 +444,7 @@ $app->get('/testset/:testset/:project', function($testset, $project) use($app)
{
$testset = strip_tags($testset);
$project = strip_tags($project);
+ $dbStatus = Factory::db()->getDbRefreshStatus();
if (Factory::checkTestset($testset)) {
$ini = Factory::conf();
$breadcrumb = array(
@@ -435,10 +454,11 @@ $app->get('/testset/:testset/:project', function($testset, $project) use($app)
$testsetProjectRoute = str_replace('/:project', '', Slim\Slim::getInstance()->urlFor('testsetproject'));
$app->render('testset.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
+ 'refreshed' => $dbStatus['refreshed'] . ' (GMT)',
'breadcrumb' => $breadcrumb,
'testsetTestfunctionsRoute' => $testsetTestfunctionsRoute,
'testsetProjectRoute' => $testsetProjectRoute,
- 'refreshed' => Factory::db()->getDbRefreshed() . ' (GMT)',
'lastDaysFailures' => $ini['top_failures_last_days'],
'lastDaysFlaky' => $ini['flaky_testsets_last_days'],
'sinceDateFailures' => Factory::getSinceDate(intval($ini['top_failures_last_days']) - 1),
@@ -462,6 +482,7 @@ $app->get('/testset/:testset/:project', function($testset, $project) use($app)
} else {
$app->render('empty.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
'message' => '404 Not Found'
));
$app->response()->status(404);
@@ -477,6 +498,7 @@ $app->get('/testset/:testset/:project/:conf', function($testset, $project, $conf
$testset = strip_tags($testset);
$project = strip_tags($project);
$conf = strip_tags($conf);
+ $dbStatus = Factory::db()->getDbRefreshStatus();
if (Factory::checkTestset($testset)) {
$testsetRoute = str_replace('/:testset/:project', '', Slim\Slim::getInstance()->urlFor('testset'));
$testsetProjectRoute = str_replace('/:project', '', Slim\Slim::getInstance()->urlFor('testsetproject'));
@@ -491,9 +513,10 @@ $app->get('/testset/:testset/:project/:conf', function($testset, $project, $conf
$testfunctionRoute = str_replace('/:testfunction/:testset/:project/:conf', '', Slim\Slim::getInstance()->urlFor('testfunction'));
$app->render('testset_testfunctions.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
+ 'refreshed' => $dbStatus['refreshed'] . ' (GMT)',
'breadcrumb' => $breadcrumb,
'testfunctionRoute' => $testfunctionRoute,
- 'refreshed' => Factory::db()->getDbRefreshed() . ' (GMT)',
'masterProject' => $ini['master_build_project'],
'masterState' => $ini['master_build_state'],
'conf' => $conf,
@@ -515,6 +538,7 @@ $app->get('/testset/:testset/:project/:conf', function($testset, $project, $conf
} else {
$app->render('empty.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
'message' => '404 Not Found'
));
$app->response()->status(404);
@@ -531,6 +555,7 @@ $app->get('/testfunction/:testfunction/:testset/:project/:conf', function($testf
$testset = strip_tags($testset);
$project = strip_tags($project);
$conf = strip_tags($conf);
+ $dbStatus = Factory::db()->getDbRefreshStatus();
if (Factory::checkTestset($testset)) {
$testsetTestfunctionRoute = str_replace('/:testset/:project/:conf', '', Slim\Slim::getInstance()->urlFor('testset_testfunctions'));
$testsetRoute = str_replace('/:testset/:project', '', Slim\Slim::getInstance()->urlFor('testset'));
@@ -546,8 +571,9 @@ $app->get('/testfunction/:testfunction/:testset/:project/:conf', function($testf
);
$app->render('testfunction.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
+ 'refreshed' => $dbStatus['refreshed'] . ' (GMT)',
'breadcrumb' => $breadcrumb,
- 'refreshed' => Factory::db()->getDbRefreshed() . ' (GMT)',
'masterProject' => $ini['master_build_project'],
'masterState' => $ini['master_build_state'],
'conf' => $conf,
@@ -567,6 +593,7 @@ $app->get('/testfunction/:testfunction/:testset/:project/:conf', function($testf
} else {
$app->render('empty.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
'message' => '404 Not Found'
));
$app->response()->status(404);
@@ -579,11 +606,13 @@ $app->get('/testfunction/:testfunction/:testset/:project/:conf', function($testf
$app->get('/sitemap', function() use($app)
{
+ $dbStatus = Factory::db()->getDbRefreshStatus();
$breadcrumb = array(
array('name' => 'home', 'link' => Slim\Slim::getInstance()->urlFor('root'))
);
$app->render('image.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
'breadcrumb' => $breadcrumb,
'title' => 'Site Map',
'navi_title' => 'site map',
@@ -598,11 +627,13 @@ $app->get('/sitemap', function() use($app)
$app->add(new HttpBasicAuthRoute('Protected Area', 'admin'));
$app->get('/admin', function() use($app)
{
+ $dbStatus = Factory::db()->getDbRefreshStatus();
$breadcrumb = array(
array('name' => 'home', 'link' => Slim\Slim::getInstance()->urlFor('root'))
);
$app->render('admin.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
'breadcrumb' => $breadcrumb,
'adminRoute' => Slim\Slim::getInstance()->urlFor('admin'),
'adminBranchesRoute' => Slim\Slim::getInstance()->urlFor('admin_branches'),
@@ -618,12 +649,14 @@ $app->get('/admin', function() use($app)
$app->add(new HttpBasicAuthRoute('Protected Area', 'admin/branches'));
$app->get('/admin/branches', function() use($app)
{
+ $dbStatus = Factory::db()->getDbRefreshStatus();
$breadcrumb = array(
array('name' => 'home', 'link' => Slim\Slim::getInstance()->urlFor('root')),
array('name' => 'admin', 'link' => Slim\Slim::getInstance()->urlFor('admin'))
);
$app->render('admin_branches.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
'breadcrumb' => $breadcrumb,
'adminRoute' => Slim\Slim::getInstance()->urlFor('admin'),
'adminBranchesRoute' => Slim\Slim::getInstance()->urlFor('admin_branches'),
@@ -639,12 +672,14 @@ $app->get('/admin/branches', function() use($app)
$app->add(new HttpBasicAuthRoute('Protected Area', 'admin/data'));
$app->get('/admin/data', function() use($app)
{
+ $dbStatus = Factory::db()->getDbRefreshStatus();
$breadcrumb = array(
array('name' => 'home', 'link' => Slim\Slim::getInstance()->urlFor('root')),
array('name' => 'admin', 'link' => Slim\Slim::getInstance()->urlFor('admin'))
);
$app->render('admin_data.html', array(
'root' => Slim\Slim::getInstance()->urlFor('root'),
+ 'dbStatus' => $dbStatus,
'breadcrumb' => $breadcrumb,
'adminRoute' => Slim\Slim::getInstance()->urlFor('admin'),
'adminBranchesRoute' => Slim\Slim::getInstance()->urlFor('admin_branches'),
diff --git a/non-puppet/qtmetrics2/scripts/reload.js b/non-puppet/qtmetrics2/scripts/reload.js
new file mode 100644
index 0000000..1b6b353
--- /dev/null
+++ b/non-puppet/qtmetrics2/scripts/reload.js
@@ -0,0 +1,43 @@
+/*
+#############################################################################
+##
+## Copyright (C) 2015 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the Quality Assurance module of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL21$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see http://www.qt.io/terms-conditions. For further
+## information use the contact form at http://www.qt.io/contact-us.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU Lesser
+## General Public License version 2.1 or version 3 as published by the Free
+## Software Foundation and appearing in the file LICENSE.LGPLv21 and
+## LICENSE.LGPLv3 included in the packaging of this file. Please review the
+## following information to ensure the GNU Lesser General Public License
+## requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+##
+## As a special exception, The Qt Company gives you certain additional
+## rights. These rights are described in The Qt Company LGPL Exception
+## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+/**
+ * Show About window
+ * @since 15-09-2015
+ * @author Juha Sippola
+ */
+
+$('.reload_page').click(function(e){
+ window.location.reload();
+});
diff --git a/non-puppet/qtmetrics2/src/Database.php b/non-puppet/qtmetrics2/src/Database.php
index b8909b0..c589a3d 100644
--- a/non-puppet/qtmetrics2/src/Database.php
+++ b/non-puppet/qtmetrics2/src/Database.php
@@ -34,7 +34,7 @@
/**
* Database class
- * @since 09-09-2015
+ * @since 15-09-2015
* @author Juha Sippola
*/
@@ -1266,13 +1266,39 @@ class Database {
*/
public function getDbRefreshed()
{
- $query = $this->db->prepare("SELECT refreshed FROM db_status ORDER BY refreshed DESC LIMIT 1");
+ $query = $this->db->prepare("
+ SELECT refreshed
+ FROM db_status
+ ORDER BY refreshed DESC LIMIT 1");
$query->execute(array());
$row = $query->fetch(PDO::FETCH_ASSOC);
$timestamp = $row['refreshed'];
return $timestamp;
}
+ /**
+ * Get the database refresh status
+ * @return array (bool in_progress, int current, int total)
+ */
+ public function getDbRefreshStatus()
+ {
+ $result = array();
+ $query = $this->db->prepare("
+ SELECT refreshed, refresh_in_progress, logs_current, logs_total
+ FROM db_status
+ ORDER BY refreshed DESC LIMIT 1;
+ ");
+ $query->execute(array());
+ $row = $query->fetch(PDO::FETCH_ASSOC);
+ $result = array(
+ 'refreshed' => $row['refreshed'],
+ 'in_progress' => $row['refresh_in_progress'],
+ 'current' => $row['logs_current'],
+ 'total' => $row['logs_total']
+ );
+ return $result;
+ }
+
}
?>
diff --git a/non-puppet/qtmetrics2/src/test/DatabaseTest.php b/non-puppet/qtmetrics2/src/test/DatabaseTest.php
index 06ec0ef..69f5058 100644
--- a/non-puppet/qtmetrics2/src/test/DatabaseTest.php
+++ b/non-puppet/qtmetrics2/src/test/DatabaseTest.php
@@ -38,7 +38,7 @@ require_once(__DIR__.'/../Factory.php');
* Database unit test class
* Some of the tests require the test data as inserted into database with qtmetrics_insert.sql
* @example To run (in qtmetrics root directory): php <path-to-phpunit>/phpunit.phar ./src/test
- * @since 09-09-2015
+ * @since 15-09-2015
* @author Juha Sippola
*/
@@ -1035,7 +1035,33 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
$timestamp = $db->getDbRefreshed();
$this->assertNotEmpty($timestamp);
$this->assertStringStartsWith('20', $timestamp);
- $this->assertEquals(19, strlen($timestamp)); // e.g. "2015-05-04 10:00:00"
+ $this->assertEquals(19, strlen($timestamp)); // e.g. "2015-05-04 10:00:00"
+ }
+
+ /**
+ * Test getDbRefreshStatus
+ * @dataProvider testGetDbRefreshStatusData
+ */
+ public function testGetDbRefreshStatus($exp_in_progress, $exp_current, $exp_total)
+ {
+ $items = array();
+ $db = Factory::db();
+ $result = $db->getDbRefreshStatus();
+ $this->assertNotEmpty($result);
+ $this->assertArrayHasKey('refreshed', $result);
+ $this->assertArrayHasKey('in_progress', $result);
+ $this->assertArrayHasKey('current', $result);
+ $this->assertArrayHasKey('total', $result);
+ $this->assertEquals(19, strlen($result['refreshed'])); // e.g. "2015-05-04 10:00:00"
+ $this->assertEquals($exp_in_progress, $result['in_progress']);
+ $this->assertEquals($exp_current, $result['current']);
+ $this->assertEquals($exp_total, $result['total']);
+ }
+ public function testGetDbRefreshStatusData()
+ {
+ return array(
+ array(0, 0, 0)
+ );
}
}
diff --git a/non-puppet/qtmetrics2/templates/about.html b/non-puppet/qtmetrics2/templates/about.html
index 5f83d77..4f5ac36 100644
--- a/non-puppet/qtmetrics2/templates/about.html
+++ b/non-puppet/qtmetrics2/templates/about.html
@@ -34,7 +34,7 @@
/**
* About window content
- * @since 09-09-2015
+ * @since 15-09-2015
* @author Juha Sippola
*/
@@ -43,4 +43,4 @@
<p>This is Qt Metrics revision 2 with redesigned UI and database.</p>
<p>These pages are still <strong>under construction</strong> and therefore the views and functionality is limited.</p>
<p>See the <a href="https://wiki.qt.io/Qt_Metrics_2_Backlog" target="_blank">backlog</a> for development items currently identified or in progress.</p>
-<p><small>Version 0.23 (9-Sep-2015)</small></p>
+<p><small>Version 0.24 (15-Sep-2015)</small></p>
diff --git a/non-puppet/qtmetrics2/templates/footer.html b/non-puppet/qtmetrics2/templates/footer.html
index a99aa49..d8720e6 100644
--- a/non-puppet/qtmetrics2/templates/footer.html
+++ b/non-puppet/qtmetrics2/templates/footer.html
@@ -34,8 +34,7 @@
/**
* Footer section of html page including the scripts
- * @version 0.5
- * @since 10-07-2015
+ * @since 15-09-2015
* @author Juha Sippola
*/
@@ -67,3 +66,6 @@
{# Loading progress bar #}
<script src="scripts/loading.js"></script>
+
+{# Page reload #}
+<script src="scripts/reload.js"></script>
diff --git a/non-puppet/qtmetrics2/templates/header.html b/non-puppet/qtmetrics2/templates/header.html
index a280992..4169649 100644
--- a/non-puppet/qtmetrics2/templates/header.html
+++ b/non-puppet/qtmetrics2/templates/header.html
@@ -34,8 +34,7 @@
/**
* Header section of html page including the meta data and style sheets
- * @version 0.6
- * @since 23-07-2015
+ * @since 15-09-2015
* @author Juha Sippola
*/
@@ -103,6 +102,21 @@
<div id="navbar" class="navbar-collapse collapse">
<nav>
<ul class="nav nav-pills pull-right">
+{# Indicate the database update status and possible refresh in progress #}
+{% if dbStatus.in_progress %}
+{% set statusIcon = 'glyphicon glyphicon-refresh green' %}
+{% if dbStatus.total <= 1 %}
+{% set statusText = 'Updating data (parsing logs) ...' %}
+{% else %}
+{% set statusText = 'Updating data (saving ' ~ dbStatus.current ~ '/' ~ dbStatus.total ~ ') ...' %}
+{% endif %}
+{% else %}
+{% set statusIcon = 'glyphicon glyphicon-dashboard green' %}
+{% set statusText = 'Last update on ' ~ dbStatus.refreshed ~ ' (GMT)' %}
+{% endif %}
+<li role="presentation" class="navbar-btn reload_page" title="{{ statusText }}">
+<a><span class="{{ statusIcon }}"></span></a>
+</li>
<li role="presentation" class=" navbar-btn dropdown">
<a id="doc-drop" href="#" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" role="button" aria-expanded="false">
Documentation