public function api_findnewjob() { $bot = new Bot($this->args('bot_id')); if (!$bot->isHydrated()) { throw new Exception("Bot does not exist."); } if (!$bot->isMine()) { throw new Exception("This bot is not yours."); } //load up our data. $data = array(); $jobs = $bot->getQueue()->getJobs('available')->getRange(0, 1); if (!empty($jobs)) { $data = $jobs[0]['Job']->getAPIData(); } //record our bot as having checked in. $bot->set('last_seen', date("Y-m-d H:i:s")); $bot->save(); return $data; }
public function api_findnewjob() { $bot = new Bot($this->args('bot_id')); if (!$bot->isHydrated()) { throw new Exception("Bot does not exist."); } if (!$bot->isMine()) { throw new Exception("This bot is not yours."); } //can we slice? $can_slice = $this->args('can_slice') && $bot->get('slice_engine_id') && $bot->get('slice_config_id'); //load up our data. $data = array(); $job = $bot->getQueue()->findNewJob($can_slice); if ($job->isHydrated()) { $data = $job->getAPIData(); } //record our bot as having checked in. // This returns the new bot, but it's currently not needed $this->_markBotAsSeen($bot); return $data; }