Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit b788c6f

Browse files
committed
ENH: refs #917. Show user's unofficial submissions on trend plot
Also show which user submitted the scalar on the scalar details page
1 parent e7f16f0 commit b788c6f

File tree

7 files changed

+45
-8
lines changed

7 files changed

+45
-8
lines changed

modules/tracker/controllers/ScalarController.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ public function detailsAction()
5252
}
5353
$this->view->resultItems = $this->Tracker_Scalar->getAssociatedItems($scalar);
5454
$this->view->otherValues = $this->Tracker_Scalar->getOtherValuesFromSubmission($scalar);
55+
56+
if($scalar->getUserId() != -1)
57+
{
58+
$this->view->submittedBy = $scalar->getUser();
59+
}
60+
else
61+
{
62+
$this->view->submittedBy = null;
63+
}
5564
}
5665

5766
/**

modules/tracker/controllers/TrendController.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public function viewAction()
6262
$startDate = date('Y-m-d H:i:s', $startDate);
6363
$endDate = date('Y-m-d H:i:s', $endDate);
6464

65+
$userId = $this->userSession->Dao ? $this->userSession->Dao->getKey() : null;
66+
6567
$trendIds = explode(' ', trim(str_replace(',', ' ', $trendId)));
6668
$this->view->trends = array();
6769
foreach($trendIds as $trendId)
@@ -72,7 +74,7 @@ public function viewAction()
7274
{
7375
throw new Zend_Exception('Read permission required on the community', 403);
7476
}
75-
$this->view->json['tracker']['scalars'][] = $this->Tracker_Trend->getScalars($trend, $startDate, $endDate);
77+
$this->view->json['tracker']['scalars'][] = $this->Tracker_Trend->getScalars($trend, $startDate, $endDate, $userId);
7678
$this->view->json['tracker']['trends'][] = $trend;
7779
$this->view->trends[] = $trend;
7880
}
@@ -117,7 +119,7 @@ public function viewAction()
117119
if(isset($rightTrend))
118120
{
119121
$this->view->json['tracker']['rightTrend'] = $rightTrend;
120-
$this->view->json['tracker']['rightScalars'] = $this->Tracker_Trend->getScalars($rightTrend, $startDate, $endDate);
122+
$this->view->json['tracker']['rightScalars'] = $this->Tracker_Trend->getScalars($rightTrend, $startDate, $endDate, $userId);
121123
}
122124
$this->view->json['tracker']['initialStartDate'] = date('n/j/Y', strtotime($startDate));
123125
$this->view->json['tracker']['initialEndDate'] = date('n/j/Y', strtotime($endDate));
@@ -149,6 +151,9 @@ public function scalarsAction()
149151
$rightTrendId = $this->_getParam('rightTrendId');
150152
$startDate = $this->_getParam('startDate');
151153
$endDate = $this->_getParam('endDate');
154+
155+
$userId = $this->userSession->Dao ? $this->userSession->Dao->getKey() : null;
156+
152157
if(!isset($trendId))
153158
{
154159
throw new Zend_Exception('Must pass trendId parameter');
@@ -166,7 +171,7 @@ public function scalarsAction()
166171
{
167172
throw new Zend_Exception('Read permission required on the community', 403);
168173
}
169-
$scalars[] = $this->Tracker_Trend->getScalars($trend, $startDate, $endDate);
174+
$scalars[] = $this->Tracker_Trend->getScalars($trend, $startDate, $endDate, $userId);
170175
}
171176
$retVal = array('status' => 'ok', 'scalars' => $scalars);
172177

modules/tracker/models/base/ScalarModelBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public abstract function getByTrendAndTimestamp($trendId, $timestamp, $user = nu
4949

5050
/**
5151
* Add a new scalar point to the trend. If overwrite is true, and a scalar
52-
* already exists on the trend with the same submit time, this will replace that scalar value.
52+
* already exists on the trend with the same submit time and user, this will replace that scalar value.
5353
*/
5454
public function addToTrend($trend, $submitTime, $producerRevision, $value, $user, $overwrite = true, $official = true)
5555
{

modules/tracker/models/base/TrendModelBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct()
5858

5959
public abstract function getMatch($producerId, $metricName, $configItemId, $testDatasetId, $truthDatasetId);
6060
public abstract function getAllByParams($params);
61-
public abstract function getScalars($trend, $startDate = null, $endDate = null);
61+
public abstract function getScalars($trend, $startDate = null, $endDate = null, $userId = null);
6262
public abstract function getTrendsGroupByDatasets($producerDao);
6363

6464
/**

modules/tracker/models/pdo/TrendModel.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getMatch($producerId, $metricName, $configItemId, $testDatasetId
5858
/**
5959
* Return chronologically ordered list of scalars for this trend
6060
*/
61-
public function getScalars($trend, $startDate = null, $endDate = null)
61+
public function getScalars($trend, $startDate = null, $endDate = null, $userId = null)
6262
{
6363
$sql = $this->database->select()
6464
->setIntegrityCheck(false)
@@ -73,6 +73,14 @@ public function getScalars($trend, $startDate = null, $endDate = null)
7373
{
7474
$sql->where('submit_time <= ?', $endDate);
7575
}
76+
if($userId)
77+
{
78+
$sql->where('official = 1 OR user_id = ?', $userId);
79+
}
80+
else
81+
{
82+
$sql->where('official = 1');
83+
}
7684
$scalars = array();
7785
$rowset = $this->database->fetchAll($sql);
7886
foreach($rowset as $row)

modules/tracker/public/js/trend/trend.view.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ midas.tracker.bindPlotEvents = function () {
7676
scalarId = json.tracker.rightScalars[pointIndex].scalar_id;
7777
}
7878
midas.loadDialog('scalarPoint'+scalarId, '/tracker/scalar/details?scalarId='+scalarId);
79-
midas.showDialog('Scalar details', false);
79+
midas.showDialog('Scalar details', false, {width: 500});
8080
});
8181
};
8282

8383
midas.tracker.renderChartArea = function (curveData, first) {
84+
console.log(curveData);
8485
if(midas.tracker.plot) {
8586
midas.tracker.plot.destroy();
8687
}

modules/tracker/views/scalar/details.phtml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,21 @@ PURPOSE. See the above copyright notices for more information.
2020
<table class="scalarInfoTable"><tbody>
2121
<tr><th>Metric:</th><td><span id="thisMetric"><?php echo $this->scalar->getTrend()->getMetricName(); ?></span></td></tr>
2222
<tr><th>Value:</th><td><span id="thisValue"><?php echo $this->scalar->getValue().' '.$this->scalar->getTrend()->getUnit(); ?></span></td></tr>
23-
<tr><th>Submitted:</th><td><span id="thisSubmitTime"><?php echo $this->scalar->getSubmitTime(); ?></span></td></tr>
23+
<tr><th>Submitted:</th>
24+
<td>
25+
<span id="thisSubmitTime"><?php echo $this->scalar->getSubmitTime(); ?></span>
26+
<?php
27+
if($this->submittedBy)
28+
{
29+
echo ' by <a href="'.$this->webroot.'/user/'.$this->submittedBy->getKey().'">'.$this->submittedBy->getFullName().'</a> ';
30+
}
31+
if(!$this->scalar->getOfficial())
32+
{
33+
echo '(unofficial)';
34+
}
35+
?>
36+
</td>
37+
</tr>
2438
<tr><th>Revision:</th><td><span id="thisProducerRev"><?php echo $this->revisionHtml; ?></span></td></tr>
2539
</tbody></table>
2640
</div>

0 commit comments

Comments
 (0)