コード例 #1
0
 public function actionUpdateAuto()
 {
     $now = (int) (@$_SERVER['REQUEST_TIME'] ?: time());
     $query = Splatfest::find()->with(['region'])->andWhere(['<=', '{{splatfest}}.[[start_at]]', date('Y-m-d\\TH:i:sP', $now)])->andWhere(['>', '{{splatfest}}.[[end_at]]', date('Y-m-d\\TH:i:sP', $now - 120)])->orderBy('{{splatfest}}.[[id]] ASC');
     foreach ($query->all() as $fest) {
         try {
             $this->actionUpdate($fest->region->key, $fest->order);
         } catch (\Exception $e) {
             echo "Catch exception: " . $e->getMessage() . "\n";
         }
     }
 }
コード例 #2
0
 private function doInit()
 {
     if (!($form = $this->createAndValidateRequestForm())) {
         throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
     }
     $this->fest = Splatfest::find()->innerJoinWith('region', false)->andWhere(['{{region}}.[[key]]' => $form->region, '{{splatfest}}.[[order]]' => $form->order])->limit(1)->one();
     if (!$this->fest) {
         throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
     }
     $this->alpha = SplatfestTeam::findOne(['fest_id' => $this->fest->id, 'team_id' => 1]);
     $this->bravo = SplatfestTeam::findOne(['fest_id' => $this->fest->id, 'team_id' => 2]);
     if (!$this->alpha || !$this->bravo) {
         throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
     }
 }
コード例 #3
0
 private function needUpdateSplatfest()
 {
     // データが何もなければ取得が必要
     $count = SplatfestMap::find()->innerJoinWith(['splatfest', 'splatfest.region'])->andWhere(['{{region}}.[[key]]' => 'jp'])->count();
     if ($count < 1) {
         return true;
     }
     // 今がフェス中でなければ不要
     $now = gmdate('Y-m-d\\TH:i:sP', (int) (@$_SERVER['REQUEST_TIME'] ?: time()));
     $fest = Splatfest::find()->innerJoinWith('region', false)->andWhere(['and', ['{{region}}.[[key]]' => 'jp'], ['<=', '{{splatfest}}.[[start_at]]', $now], ['>', '{{splatfest}}.[[end_at]]', $now]])->one();
     if (!$fest) {
         return false;
     }
     // マップ情報をもっていれば不要
     $count = SplatfestMap::find()->andWhere(['{{splatfest_map}}.[[splatfest_id]]' => $fest->id])->count();
     return $count < 1;
 }