Skip to content

Commit

Permalink
change the computeAccuracy method so it can be used in post select tr…
Browse files Browse the repository at this point in the history
…igger #34
  • Loading branch information
MathieuNls committed Dec 18, 2015
1 parent 0c210bc commit 6e69cb8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions application/core/MY_Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ public function trigger($event, $data = false) {
$this->callback_parameters = explode(',', $matches[3]);
}

$data = call_user_func_array(array($this, $method), array($data));
$data = call_user_func_array(array($this, $method), array(&$data));
}

return $data;
Expand Down Expand Up @@ -1905,4 +1905,4 @@ public function last_query() {return $this->db->last_query();}
public function truncate() {$this->db->truncate($this->table_name);}
public function inserted_id() {return $this->db->insert_id();}

}
}
23 changes: 12 additions & 11 deletions application/models/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ class Email extends MY_Model {
* Theses ids are used to ensure that
* an email isn't sent twice for an user.
*/
public const $ADD_FIRST_WATCH = 1;
public const $CHECK_ACCURACY = 2;
public const $ADD_SECOND_WATCH = 3;
public const $START_NEW_MEASURE = 4;
public const $COMEBACK = 5;
public const $START_FIRST_MEASURE = 6;
public const $CHECK_ACCURACY_1_WEEK = 7;

private const $hour = 3600;
private const $day = 86400;
private const $cancelledEmail = 1;
public $ADD_FIRST_WATCH = 1;
public $CHECK_ACCURACY = 2;
public $ADD_SECOND_WATCH = 3;
public $START_NEW_MEASURE = 4;
public $COMEBACK = 5;
public $START_FIRST_MEASURE = 6;
public $CHECK_ACCURACY_1_WEEK = 7;

private $hour = 3600;
private $day = 86400;
private $cancelledEmail = 1;

/**
* Load model, library and helpers
Expand Down Expand Up @@ -157,6 +157,7 @@ private function insertAll($array, $model){
}
}


private function sendMandrillEmail($subject, $content, $recipientName,
$recipientEmail, $tags, $sendAt, $attachments = null) {

Expand Down
4 changes: 2 additions & 2 deletions application/models/Measure.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function getMeasuresByUser($userId, $userWatches) {
foreach ($watchMeasures as $watchMeasure) {
//Compute accuracy
if ($watchMeasure->statusId == 2) {
$data[$dataPushing]['accuracy'] = sprintf("%.1f", $this->computeAccuracy($watchMeasure));
$data[$dataPushing]['accuracy'] = $watchMeasure->accuracy;//sprintf("%.1f", $this->computeAccuracy($watchMeasure));
$data[$dataPushing]['statusId'] = $watchMeasure->statusId;
//Check if the measure was made less than 12 hours ago
} else if (((time()-$watchMeasure->measureReferenceTime)/3600) < 12) {
Expand Down Expand Up @@ -71,7 +71,7 @@ public function computeAccuracy(&$watchMeasure) {
$accuracy = ($userDelta*86400/$refDelta)-86400;
$accuracy = sprintf("%.1f", $accuracy);
$watchMeasure->accuracy = $accuracy;
return $accuracy;
return $watchMeasure;
}

function addBaseMesure($watchId, $referenceTime, $userTime) {
Expand Down
2 changes: 2 additions & 0 deletions application/tests/controllers/Ajax_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ public function test_accuracyMeasure() {
$CI->load->model('Measure');
$measure = $CI->Measure->find_by('watchId', self::$watchId);

var_dump($measure);

$output = $this->request(
'POST',
['Ajax', 'accuracyMeasure'],
Expand Down

0 comments on commit 6e69cb8

Please sign in to comment.