static function setUpColumns($columns) { $columns->id = Column::AUTO_ID; $columns->wakaUserId = WakaUser::columns()->id; $columns->dateUt = Column::TIMESTAMP + Column::NOT_NULL; $columns->name = Column::STRING + Column::NOT_NULL; $columns->type = Column::STRING + Column::NOT_NULL; $columns->weight = Column::INTEGER; $columns->seconds = Column::INTEGER + Column::NOT_NULL; }
static function setUpColumns($columns) { $columns->id = Column::create(Column::INTEGER + Column::AUTO_ID + Column::NOT_NULL + Column::UNSIGNED); $columns->wakaUserId = WakaUser::columns()->id; $columns->branch = Column::create(Column::STRING); $columns->duration = Column::create(Column::FLOAT + Column::NOT_NULL); $columns->entity = Column::create(Column::STRING); $columns->language = Column::create(Column::STRING); $columns->project = Column::create(Column::STRING); $columns->time = Column::create(Column::INTEGER); $columns->type = Column::create(Column::STRING); }
public function getDurations() { $now = $this->time->now(); $maxLastFetch = $now - self::FETCH_INTERVAL - rand(0, self::FETCH_RANDOM); do { /** @var WakaUser[] $users */ $users = WakaUser::statement()->where('? < ?', WakaUser::columns()->lastFetch, $maxLastFetch)->limit(5)->query()->fetchAll(); foreach ($users as $user) { print_r($user); $this->getDurationsByUser($user); $user->lastFetch = $now; $user->save(); } } while (count($users)); }
<?php namespace WakaBot; require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/env/conf.php'; $log = new \Yaoi\Log('colored-stdout'); \WakaBot\Duration::table()->migration()->setLog($log)->apply(); \WakaBot\DayStat::table()->migration()->setLog($log)->apply(); \WakaBot\WakaUser::table()->migration()->setLog($log)->apply();