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

Commit 3f38056

Browse files
committed
Clarify documentation and fix expectation when using current day in Tracker Submission Model API.
1 parent 783392e commit 3f38056

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

modules/tracker/models/base/SubmissionModelBase.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,14 @@ abstract public function getSubmissionsByProducer($producerDao);
9292
abstract public function getScalars($submissionDao, $key = false);
9393

9494
/**
95-
* Get submissions associated with a given producer.
95+
* Get the single latest submission associated with a given producer.
9696
*
9797
* @param Tracker_ProducerDao $producerDao producer DAO
98-
* @param false | string $date the date in which to check
98+
* @param false | string $date the latest time end the 24-hour interval or false to use the current day.
9999
* @param string $branch the branch of the submission for which to search
100-
* @param bool $onlyOneDay whether to only get the last day.
101-
* @return Tracker_SubmissionDao submission
100+
* @param bool $onlyOneDay true to return submissions 24 hours back from $date, false otherwise. In the case of the
101+
* of $date === false, $onlyOneDay will search only in the current day.
102+
* @return false | Tracker_SubmissionDao submission
102103
*/
103104
abstract public function getLatestSubmissionByProducerDateAndBranch($producerDao,
104105
$date = false,
@@ -107,9 +108,10 @@ abstract public function getLatestSubmissionByProducerDateAndBranch($producerDao
107108

108109
/**
109110
* Get trends associated with a submission.
111+
*
110112
* @param Tracker_SubmissionDao $submissionDao submission DAO
111-
* @param bool $key whether to only retrieve key trends
112-
* @return array trend DAOs
113+
* @param bool $key true if only key trends should be returned, false otherwise.
114+
* @return array Tracker_TrendDaos
113115
*/
114116
abstract public function getTrends($submissionDao, $key = true);
115117
}

modules/tracker/models/pdo/SubmissionModel.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,22 @@ public function getOrCreateSubmission($producerDao, $uuid)
154154
}
155155

156156
/**
157-
* Get submissions associated with a given producer.
157+
* Get the single latest submission associated with a given producer.
158158
*
159159
* @param Tracker_ProducerDao $producerDao producer DAO
160-
* @param false | string $date the date in which to check
160+
* @param false | string $date the latest time end the 24-hour interval or false to use the current day.
161161
* @param string $branch the branch of the submission for which to search
162-
* @param bool $onlyOneDay whether to only get the last day.
163-
* @return Tracker_SubmissionDao submission | false
162+
* @param bool $onlyOneDay true to return submissions 24 hours back from $date, false otherwise. In the case of the
163+
* of $date === false, $onlyOneDay will search only in the current day.
164+
* @return false | Tracker_SubmissionDao submission
164165
*/
165166
public function getLatestSubmissionByProducerDateAndBranch($producerDao, $date = false, $branch = 'master',
166167
$onlyOneDay = true)
167168
{
168169
if ($date) {
169170
$queryTime = date('Y-m-d H:i:s', strtotime($date));
170171
} else {
171-
$queryTime = date('Y-m-d H:i:s', time());
172+
$queryTime = date('Y-m-d', time()) . '23:59:59';
172173
}
173174
$dayBeforeQueryTime = date('Y-m-d H:i:s', strtotime($queryTime) - self::SEC_IN_DAY);
174175
$sql = $this->database->select()->setIntegrityCheck(false)
@@ -197,22 +198,20 @@ public function getLatestSubmissionByProducerDateAndBranch($producerDao, $date =
197198

198199
/**
199200
* Get trends associated with a submission.
201+
*
200202
* @param Tracker_SubmissionDao $submissionDao submission DAO
201-
* @param bool $key whether to only retrieve key trends
202-
* @return array trend DAOs
203+
* @param bool $key true if only key trends should be returned, false otherwise.
204+
* @return array Tracker_TrendDaos
203205
*/
204206
public function getTrends($submissionDao, $key = true)
205207
{
208+
$sql = $this->database->select()->setIntegrityCheck(false)->from('tracker_trend')->join(
209+
'tracker_scalar',
210+
'tracker_scalar.trend_id = tracker_trend.trend_id',
211+
array()
212+
)->where('submission_id = ?', $submissionDao->getKey());
206213
if ($key) {
207-
$sql = $this->database->select()->setIntegrityCheck(false)->from('tracker_trend')->join(
208-
'tracker_scalar',
209-
'tracker_scalar.trend_id = tracker_trend.trend_id',
210-
array()
211-
)->where('submission_id = ?', $submissionDao->getKey()
212-
)->where('key_metric = ?', 1);
213-
} else {
214-
$sql = $this->database->select()->setIntegrityCheck(false)->from('tracker_scalar')
215-
->where('submission_id = ?', $submissionDao->getKey());
214+
$sql = $sql->where('key_metric = ?', 1);
216215
}
217216
$trendDaos = array();
218217
$rows = $this->database->fetchAll($sql);

0 commit comments

Comments
 (0)