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
 private function seriesFill()
 {
     if (self::DATA_TYPE_NAMED === $this->dataType) {
         $this->rows = Processor::create($this->rows)->combineOffset(2, 1);
     }
     foreach ($this->rows as $row) {
         $xValue = array_shift($row);
         foreach ($row as $key => $value) {
             $this->highCharts->addRow($xValue, $value, $key);
         }
     }
 }
Exemplo n.º 3
0
 public function performAction()
 {
     $album = Album::findByPrimaryKey($this->albumId);
     if (!$album) {
         throw new \Exception('Album not found');
     }
     $images = Image::statement()->where('? = ?', Image::columns()->albumId, $this->albumId)->query()->fetchAll();
     if ($images) {
         $this->response->addContent(new Rows(Processor::create($images)->map(function (Image $image) {
             $row = array();
             $row['Path'] = $image->path;
             $row['Url'] = $image->url;
             return $row;
         })));
     }
     $uploadHandler = Upload::createState();
     $uploadHandler->albumId = $this->albumId;
     $uploadUrl = (string) $this->io->makeAnchor($uploadHandler);
     $this->response->addContent(new Form($uploadUrl));
 }
Exemplo n.º 4
0
 public function performAction()
 {
     if (!($user = AuthService::getInstance()->getUser())) {
         throw new \Exception('Authenticated user required');
     }
     $this->response->success('CATALOGE!');
     /** @var Album[] $albums */
     $albums = Album::statement()->where('? = ?', Album::columns()->userId, $user->id)->query()->fetchAll();
     $this->response->addContent(new Form(Create::createState(), $this->io));
     $details = Details::createState();
     if ($albums) {
         $this->response->addContent(new Rows(Processor::create($albums)->map(function (Album $album) use($details) {
             $row = array();
             $details->albumId = $album->id;
             $anchor = $this->io->makeAnchor($details);
             $row['Title'] = new Anchor($album->title, $anchor);
             $row['Created'] = date('Y-m-d H:i:s', $album->created);
             $row['Updated'] = date('Y-m-d H:i:s', $album->updated);
             $row['Images'] = $album->imagesCount;
             return $row;
         })));
     }
 }