Exemplo n.º 1
0
 public function performAction()
 {
     $userCols = WakaUser::columns();
     $statCols = Stat7Days::columns();
     $detCols = Stat7Details::columns();
     $typeCols = StatType::columns();
     $exprDaily = Stat7Days::statement()->select('GROUP_CONCAT(?)', $statCols->dailyAverage)->where('? = ?', $statCols->userId, $userCols->id)->groupBy($statCols->userId);
     $exprTotal = Stat7Days::statement()->select('GROUP_CONCAT(?)', $statCols->totalSeconds)->where('? = ?', $statCols->userId, $userCols->id)->groupBy($statCols->userId);
     $exprLang = Stat7Details::statement()->select('GROUP_CONCAT(? || ":" || cast(? as int))', $typeCols->type, $detCols->percent)->innerJoin('? ON ? = ?', StatType::table(), $typeCols->id, $detCols->typeId)->where('? = ?', $detCols->stat7id, $userCols->latestStatId)->where('? > 10 AND ? = ?', $detCols->percent, $typeCols->section, 'languages');
     $res = WakaUser::statement()->select('? AS User,round(?/3600.0, 2) AS "Dly, h", ? AS Daily,round(?/3600.0, 2) AS "Tot, h", ? AS H, ? AS Specialty', $userCols->userName, $statCols->dailyAverage, $exprDaily, $statCols->totalSeconds, $statCols->holidays, $exprLang)->leftJoin('? ON ? = ?', Stat7Days::table(), $statCols->id, $userCols->latestStatId)->order('? DESC', Stat7Days::columns()->totalSeconds)->bindResultClass()->query()->fetchAll();
     $minDaily = $maxDaily = null;
     foreach ($res as &$item) {
         $item['Daily'] = explode(',', $item['Daily']);
         if (null === $minDaily) {
             $minDaily = min($item['Daily']);
             $maxDaily = max($item['Daily']);
         } else {
             $minDaily = min($minDaily, min($item['Daily']));
             $maxDaily = max($maxDaily, max($item['Daily']));
         }
     }
     $processor = new Processor($res);
     $processor->map(function ($row) use($minDaily, $maxDaily) {
         $dailySpark = new Text(Spark::getString($row['Daily'], $minDaily, $maxDaily));
         $dailySpark->forceLength = strlen($dailySpark->value) / 3;
         $row['Daily'] = $dailySpark;
         //$row['Total'] = Spark::getString(explode(',', $row['Total']));
         return $row;
     });
     //print_r($res->fetchAll());
     $this->response->addContent(new Rows($processor));
 }
Exemplo n.º 2
0
 public function performAction()
 {
     /** @var Migration[] $migrations */
     $migrations = array(WakaUser::migration(), StatType::migration(), Stat7Details::migration(), Stat7Days::migration());
     $log = new Log('colored-stdout');
     if ($this->wipe) {
         foreach ($migrations as $migration) {
             $migration->setLog($log)->setDryRun($this->dryRun)->rollback();
         }
     }
     foreach ($migrations as $migration) {
         $migration->setLog($log)->setDryRun($this->dryRun)->apply();
     }
 }