@@ -154,21 +154,22 @@ public function getOrCreateSubmission($producerDao, $uuid)
154
154
}
155
155
156
156
/**
157
- * Get submissions associated with a given producer.
157
+ * Get the single latest submission associated with a given producer.
158
158
*
159
159
* @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.
161
161
* @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
164
165
*/
165
166
public function getLatestSubmissionByProducerDateAndBranch ($ producerDao , $ date = false , $ branch = 'master ' ,
166
167
$ onlyOneDay = true )
167
168
{
168
169
if ($ date ) {
169
170
$ queryTime = date ('Y-m-d H:i:s ' , strtotime ($ date ));
170
171
} else {
171
- $ queryTime = date ('Y-m-d H:i:s ' , time ());
172
+ $ queryTime = date ('Y-m-d ' , time ()) . ' 23:59:59 ' ;
172
173
}
173
174
$ dayBeforeQueryTime = date ('Y-m-d H:i:s ' , strtotime ($ queryTime ) - self ::SEC_IN_DAY );
174
175
$ sql = $ this ->database ->select ()->setIntegrityCheck (false )
@@ -197,22 +198,20 @@ public function getLatestSubmissionByProducerDateAndBranch($producerDao, $date =
197
198
198
199
/**
199
200
* Get trends associated with a submission.
201
+ *
200
202
* @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
203
205
*/
204
206
public function getTrends ($ submissionDao , $ key = true )
205
207
{
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 ());
206
213
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 );
216
215
}
217
216
$ trendDaos = array ();
218
217
$ rows = $ this ->database ->fetchAll ($ sql );
0 commit comments