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

Commit

Permalink
Clarify documentation and fix expectation when using current day in T…
Browse files Browse the repository at this point in the history
…racker Submission Model API.
  • Loading branch information
cpatrick committed Feb 1, 2016
1 parent 783392e commit 3f38056
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
14 changes: 8 additions & 6 deletions modules/tracker/models/base/SubmissionModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ abstract public function getSubmissionsByProducer($producerDao);
abstract public function getScalars($submissionDao, $key = false);

/**
* Get submissions associated with a given producer.
* Get the single latest submission associated with a given producer.
*
* @param Tracker_ProducerDao $producerDao producer DAO
* @param false | string $date the date in which to check
* @param false | string $date the latest time end the 24-hour interval or false to use the current day.

This comment has been minimized.

Copy link
@mgrauer

mgrauer Feb 1, 2016

Contributor

latest time end the 24 => maybe => latest time in the 24 ?

* @param string $branch the branch of the submission for which to search
* @param bool $onlyOneDay whether to only get the last day.
* @return Tracker_SubmissionDao submission
* @param bool $onlyOneDay true to return submissions 24 hours back from $date, false otherwise. In the case of the
* of $date === false, $onlyOneDay will search only in the current day.

This comment has been minimized.

Copy link
@mgrauer

mgrauer Feb 1, 2016

Contributor

In the case of the of => In the case of

* @return false | Tracker_SubmissionDao submission
*/
abstract public function getLatestSubmissionByProducerDateAndBranch($producerDao,
$date = false,
Expand All @@ -107,9 +108,10 @@ abstract public function getLatestSubmissionByProducerDateAndBranch($producerDao

/**
* Get trends associated with a submission.
*
* @param Tracker_SubmissionDao $submissionDao submission DAO
* @param bool $key whether to only retrieve key trends
* @return array trend DAOs
* @param bool $key true if only key trends should be returned, false otherwise.
* @return array Tracker_TrendDaos
*/
abstract public function getTrends($submissionDao, $key = true);
}
31 changes: 15 additions & 16 deletions modules/tracker/models/pdo/SubmissionModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,22 @@ public function getOrCreateSubmission($producerDao, $uuid)
}

/**
* Get submissions associated with a given producer.
* Get the single latest submission associated with a given producer.
*
* @param Tracker_ProducerDao $producerDao producer DAO
* @param false | string $date the date in which to check
* @param false | string $date the latest time end the 24-hour interval or false to use the current day.

This comment has been minimized.

Copy link
@mgrauer

mgrauer Feb 1, 2016

Contributor

update to be in sync with whatever changes from base

* @param string $branch the branch of the submission for which to search
* @param bool $onlyOneDay whether to only get the last day.
* @return Tracker_SubmissionDao submission | false
* @param bool $onlyOneDay true to return submissions 24 hours back from $date, false otherwise. In the case of the

This comment has been minimized.

Copy link
@mgrauer

mgrauer Feb 1, 2016

Contributor

update to be in sync with whatever changes from base

* of $date === false, $onlyOneDay will search only in the current day.

This comment has been minimized.

Copy link
@mgrauer

mgrauer Feb 1, 2016

Contributor

$onlyOneDay will => $onlyOneDay (if true) will

* @return false | Tracker_SubmissionDao submission
*/
public function getLatestSubmissionByProducerDateAndBranch($producerDao, $date = false, $branch = 'master',
$onlyOneDay = true)
{
if ($date) {
$queryTime = date('Y-m-d H:i:s', strtotime($date));
} else {
$queryTime = date('Y-m-d H:i:s', time());
$queryTime = date('Y-m-d', time()) . '23:59:59';
}
$dayBeforeQueryTime = date('Y-m-d H:i:s', strtotime($queryTime) - self::SEC_IN_DAY);
$sql = $this->database->select()->setIntegrityCheck(false)
Expand Down Expand Up @@ -197,22 +198,20 @@ public function getLatestSubmissionByProducerDateAndBranch($producerDao, $date =

/**
* Get trends associated with a submission.
*
* @param Tracker_SubmissionDao $submissionDao submission DAO
* @param bool $key whether to only retrieve key trends
* @return array trend DAOs
* @param bool $key true if only key trends should be returned, false otherwise.
* @return array Tracker_TrendDaos
*/
public function getTrends($submissionDao, $key = true)
{
$sql = $this->database->select()->setIntegrityCheck(false)->from('tracker_trend')->join(
'tracker_scalar',
'tracker_scalar.trend_id = tracker_trend.trend_id',
array()
)->where('submission_id = ?', $submissionDao->getKey());
if ($key) {
$sql = $this->database->select()->setIntegrityCheck(false)->from('tracker_trend')->join(
'tracker_scalar',
'tracker_scalar.trend_id = tracker_trend.trend_id',
array()
)->where('submission_id = ?', $submissionDao->getKey()
)->where('key_metric = ?', 1);
} else {
$sql = $this->database->select()->setIntegrityCheck(false)->from('tracker_scalar')
->where('submission_id = ?', $submissionDao->getKey());
$sql = $sql->where('key_metric = ?', 1);
}
$trendDaos = array();
$rows = $this->database->fetchAll($sql);
Expand Down

0 comments on commit 3f38056

Please sign in to comment.