/**
  * 
  * @param type $topicId
  * @param type $lastUpdate
  * @return int
  */
 public function actionSync($topicId, $lastUpdate)
 {
     $topic = Topic::findOne(!is_numeric($topicId) ? ['name' => $topicId] : $topicId);
     if (NULL === $topic) {
         $this->stdout("No Such Topic \n");
         return 1;
     }
     $this->stdout('processing topic: ');
     $this->stdout($topic->name . "\n", Console::FG_GREEN, Console::BOLD);
     $client = new Client();
     //Auto scoop when condition is satisfied
     if (isset($this->module->params['autoScoopTopicCondition']) && call_user_func($this->module->params['autoScoopTopicCondition'], $topic)) {
         //     $this->stdout("auto-scooping \n");
         $client->autoScoop($topic->id, $lastUpdate);
     }
     //Syncronise Scoops
     $scoops = $client->getScoops($topic->id, $lastUpdate);
     // $this->stdout("saving scoops to local storage \n");
     foreach ($scoops as $scoop) {
         $model = $this->_sync($scoop, $topic, TRUE);
     }
     //Store suggestions
     if (isset($this->module->params['saveSuggestions']) && $this->module->params['saveSuggestions']) {
         $this->stdout("saving suggestions to local storage \n");
         foreach ($client->getSources($topic->id, $lastUpdate) as $source) {
             $source = $this->_sync($source, $topic, FALSE);
         }
     }
     return 0;
 }
 /**
  * 
  * @param integer|string $topicId
  */
 public function actionRemote($topicId)
 {
     $topic = \humanized\scoopit\models\Topic::findOne(!is_numeric($topicId) ? ['name' => $topicId] : $topicId);
     if (NULL === $topic) {
         $this->stdout("No Such Topic \n");
         return 1;
     }
     $queryParams = ['action' => 'delete'];
     $client = new Client();
     foreach ($client->getScoops($topic->id) as $remoteScoop) {
         $queryParams['id'] = $remoteScoop->id;
         $client->post('api/1/post', ['query' => $queryParams]);
     }
 }