Skip to content

Commit

Permalink
Add accuracyAge attribut to measure. #35
Browse files Browse the repository at this point in the history
The accuracyAge property is used in the dashboard summary in emails (views/email/generic.php). We could use it in the 'real' dashboard to (views/measures/dashboard.php)
  • Loading branch information
MathieuNls committed Feb 3, 2016
1 parent 5041d74 commit 008d70f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions application/models/Measure.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,18 @@ public function computeAccuracy($watchMeasure) {
if(is_numeric($watchMeasure->accuracyUserTime)
&& is_numeric($watchMeasure->measureUserTime)
&& is_numeric($watchMeasure->accuracyReferenceTime)
&& is_numeric($watchMeasure->measureReferenceTime))
&& is_numeric($watchMeasure->measureReferenceTime)
&& !is_null($watchMeasure->accuracyReferenceTime)
&& !is_null($watchMeasure->measureReferenceTime))
{
$userDelta = $watchMeasure->accuracyUserTime-$watchMeasure->measureUserTime;
$refDelta = $watchMeasure->accuracyReferenceTime-$watchMeasure->measureReferenceTime;
$accuracy = ($userDelta*86400/$refDelta)-86400;
$accuracy = sprintf("%.1f", $accuracy);
$watchMeasure->accuracy = $accuracy;

$watchMeasure->accuracyAge =
round((time() - $watchMeasure->accuracyReferenceTime) / 86400);
}

//Compute 1.5 status. When a measure is less than 12 hours old
Expand Down Expand Up @@ -177,13 +182,14 @@ function addAccuracyMesure($measureId, $referenceTime, $userTime) {

$watchMeasure = $this
->select("measure.*, watch.name as model, watch.brand, user.email,
user.firstname, user.name")
user.firstname, user.name, user.userId")
->join("watch", "watch.watchId = measure.watchId")
->join("user", "user.userId = watch.userId")
->find($measureId);


$this->notify(NEW_ACCURACY,
array('measure' => $watchMeasure));
array('measure' => $watchMeasure));

$watchMeasure->percentile =
$this->computePercentileAccuracy($watchMeasure->accuracy);
Expand Down

0 comments on commit 008d70f

Please sign in to comment.