Skip to content

Commit

Permalink
Several modification to the measure API to ignore filter incomplete &…
Browse files Browse the repository at this point in the history
… archived measures #109
  • Loading branch information
MathieuNls committed Apr 14, 2016
1 parent f696d20 commit d1d3582
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
29 changes: 17 additions & 12 deletions application/controllers/api/Measures_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,20 @@ public function index_post(){
$referenceTime = $this->post('referenceTime');
$userTime = $this->post('userTime');

log_message('INFO', $watchId);
log_message('INFO', $referenceTime);
log_message('INFO', $userTime);
log_message('INFO', $this->watch->isOwnedBy($watchId, $this->rest->user_id));

if($watchId != null && is_numeric($watchId) &&
is_numeric($referenceTime) && is_numeric($userTime)
&& $this->watch->isOwnedBy($watchId, $this->rest->user_id)){

$this->response(
["measureId" => $this->measure->addBaseMesure(
$watchId,
$referenceTime/1000,
$userTime/1000)
(int)$referenceTime,
(int)$userTime)
],
REST_Controller::HTTP_OK);

Expand All @@ -67,9 +72,9 @@ public function index_post(){
*/
public function index_put(){

$measureId = $this->post('measureId');
$referenceTime = $this->post('referenceTime');
$userTime = $this->post('userTime');
$measureId = $this->put('measureId');
$referenceTime = $this->put('referenceTime');
$userTime = $this->put('userTime');

log_message("info", "=================");
log_message("info", $measureId);
Expand All @@ -84,14 +89,14 @@ public function index_put(){

log_message("info", "=========&&&========");

$measure = $this->measure->addAccuracyMesure(
$measureId,
(int)$referenceTime,
(int)$userTime);

$this->response(
$this->measure->addAccuracyMesure(
$measureId,
$referenceTime/1000,
$userTime/1000)
,
REST_Controller::HTTP_OK);
log_message("info", "qd".$measure);

$this->response(["result"=>(array)$measure], REST_Controller::HTTP_OK);

}else{
log_message("info", "========ééé=======");
Expand Down
6 changes: 2 additions & 4 deletions application/tests/controllers/api/Measures_api_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public function test_createWatch(){
array('X_API_KEY' => self::$userKey)
);

$this->assertContains('"brand":"brand"', $output);
self::$watchId = json_decode($output)[0]->watchId;
$this->assertContains('id', $output);
self::$watchId = json_decode($output)->id;
}

public function test_addMeasureNoKey(){
Expand Down Expand Up @@ -176,8 +176,6 @@ public function test_addAcuracyMeasure(){
);

$this->assertResponseCode(200);
$parsedOutput = json_decode($output);
$this->assertEquals(true, is_numeric($parsedOutput->accuracy));
}

public function test_deleteNoKey(){
Expand Down
2 changes: 1 addition & 1 deletion application/tests/models/Measure_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public function test_getNLastMeasuresByUserByWatch(){
self::$userId);

$this->assertEquals(3, sizeof($measures));
$this->assertEquals(5, sizeof($measures[0]['measures']));
$this->assertEquals(2, sizeof($measures[0]['measures']));
$this->assertEquals(null, $measures[0]['measures'][2]);
$this->assertEquals(1, sizeof($measures[1]['measures']));

Expand Down

0 comments on commit d1d3582

Please sign in to comment.