private function updateLuckyNumbers($dom) { $model = new LuckyNumberRepository(); $parser = new LuckyNumberParser(); $remote = $parser->getLuckyNumber($dom); $this->logErrors('LuckyNumberParser', $parser->getErrors()); if ($remote !== null) { $local = $model->getByDate($remote->date); if ($local === null || $remote->value !== $local->value) { $model->setValue($remote->date, $remote->value); echo "updated ln/{$remote->date}\n"; } } }
/** * @param string $date in format yyyy-mm-dd * @param int $lastModified * @return News */ public function getNews($date, $lastModified) { $now = time(); $replacements = new ReplacementsRepository(); $luckyNumbers = new LuckyNumberRepository(); $timetables = new TimetableRepository(); $bells = new BellsRepository(); $settings = new SettingRepository(); $news = new News(); $news->timestamp = $now; $news->replacements = $replacements->getByDateAndLastModified($date, $lastModified); $news->luckyNumbers = $luckyNumbers->getByDateAndLastModified($date, $lastModified); $news->timetables = $timetables->getByLastModified($lastModified); $news->bells = $bells->getByLastModified($lastModified); $news->version = (int) $settings->get('version'); return $news; }
public function GET_lucky_numbers_1($date) { $repo = new LuckyNumberRepository(); $result = $repo->getByDate($date); if ($result !== null) { Json::OK($result); } else { Json::notFound(); } }