microsoftarchive / api

The Wunderlist API Documentation
123 stars 37 forks source link

delay loading info #37

Open songpol opened 8 years ago

songpol commented 8 years ago

Hi, i implemented wunderlist api with php and everythings work fine. Excepting the response time when loading tasks or list or any action to get data from api it take around 1 minute.Does it properly response time? Any suggestion would be appreciate.

vsmart commented 8 years ago

Hi @songpol. The response time shouldn't be that high. Can you post an example request you are making?

songpol commented 8 years ago

HI @vsmart .Thanks for your commented.my code as attached.

EXWunderlist.php.zip

vsmart commented 8 years ago

Could you post (copy/paste) in this issue only the bit where you make the api call?

songpol commented 8 years ago

Hi @vsmart here is my code. <?php require_once DIR.'/vendor/autoload.php'; use JohnRivs\Wunderlist\Wunderlist; $clientId = 'MYCLIENTID'; $clientSecret = 'MYSECRET'; $accessToken = 'MYTOKEN'; $w = new Wunderlist($clientId, $clientSecret, $accessToken); $lists = $w->getLists(); $date = new DateTime(); $today = $date->format('Y-m-d'); $next7days = date('Y-m-d', strtotime('+7 days')); $tasksOverdue = array(); $tasksToday = array(); $tasksNext7 = array(); $count1 = 0; $count2 = 0; $count3 = 0;

foreach($lists as $key => $value){
    if($key == 0){
        $tasksInbox = $w->getTasks([
            'list_id' => $value["id"],
            'completed' => ''
        ]);
    }        
}
foreach($lists as $key => $value){                 
    $tasks = $w->getTasks([
        'list_id' => $value["id"],
        'completed' => ''
    ]);
    foreach($tasks as $key2 => $value2){ 
        $notes = $w->getNotes('task', [
            'task_id' => $value2["id"]
        ]);

        if($value2["due_date"] < $today && $value2["due_date"] <> ''){  //---DueDate Tasks
            $tasksOverdue[$count1] = array("id" => $value2["id"], "title" => $value2["title"], "due_date" => $value2["due_date"], "note_content" => $notes[0]["content"], "note_id" => $notes[0]["id"]);
            $count1 += 1;               
        }else if($value2["due_date"] == $today) {   //---Today Tasks
            $tasksToday[$count2] = array("id" => $value2["id"], "title" => $value2["title"], "due_date" => $value2["due_date"], "note_content" => $notes[0]["content"], "note_id" => $notes[0]["id"]);
            $count2 += 1;           
        }else if($value2["due_date"] > $today && $value2["due_date"] <= $next7days) {   //---Next 7 Days Tasks 
            $tasksNext7[$count3] = array("id" => $value2["id"], "title" => $value2["title"], "due_date" => $value2["due_date"], "note_content" => $notes[0]["content"], "note_id" => $notes[0]["id"]);
            $count3 += 1;                        
        }  
    }
}

?>

Inbox:

Over Due:

Today:

Next 7 Days:

rotev commented 8 years ago

Hi @songpol, I suggest that instead of fetching notes for each task, you'll fetch the notes for each list. This will reduce the number of HTTP calls and should make things run faster. For more information, refer to the notes documentation page.

songpol commented 8 years ago

Hi @rotev, Thanks for your commented.I will try it according your suggestion.