/** * Run the crawlers in order of their run dates */ public static function do_schedule() { $jobs = Model_Channel_Filter::get_channel_filters_by_run_date(); foreach ($jobs as $job) { self::run($job['river_id'], $job['channel']); } }
/** * Get a specific channel * * @return array */ public function get_channel($channelKey) { $channel = $this->channel_filters->where('channel', '=', $channelKey)->find(); if (!$channel->loaded()) { $channel = new Model_Channel_Filter(); $channel->channel = $channelKey; $channel->river_id = $this->id; $channel->filter_enabled = TRUE; $channel->filter_date_add = gmdate('Y-m-d H:i:s'); $channel->save(); } return $channel; }
/** * Update channel filter run statistics * * @param integer $river_id * @param string $channel * @param boolean $success * @param string $run_date * @return void */ public static function update_runs($river_id, $channel, $success, $run_date = NULL) { if (!$run_date) { $run_date = DB::expr('Now()'); } $channel_filter = Model_Channel_Filter::get_channel_filters($channel, $river_id); if ($channel_filter and $channel_filter->loaded()) { $channel_filter->filter_last_run = $run_date; if ($success) { $channel_filter->filter_last_successful_run = $run_date; } $channel_filter->filter_runs = new Database_Expression('filter_runs + 1'); $channel_filter->update(); } }