Exemplo n.º 1
0
 public static function addResult($json)
 {
     $result = new Result();
     $result->sessionId = $json['session'];
     $result->param = $json['param'];
     $result->value = $json['value'];
     $result->save();
     if (isset($json['tags'])) {
         /** @var Session $session */
         $session = Session::find($result->sessionId);
         $tagIds = array();
         foreach ($json['tags'] as $tagName) {
             $tag = new Tag();
             $tag->name = $tagName;
             $tag->findOrSave();
             $tagIds[] = $tag->id;
         }
         $series = new Series();
         $series->sessionId = $session->id;
         $series->hostId = $session->hostId;
         $series->suiteId = $session->suiteId;
         sort($tagIds);
         $series->tagIds = implode(',', $tagIds);
         $series->findOrSave();
         foreach ($tagIds as $tagId) {
             $seriesTag = new SeriesTag();
             $seriesTag->tagId = $tagId;
             $seriesTag->seriesId = $series->id;
             $seriesTag->findOrSave();
         }
     }
     return true;
 }
Exemplo n.º 2
0
 public static function migrate()
 {
     $migrationManager = new Manager();
     $migrationManager->setLog(new Log('colored-stdout'));
     $migrationManager->add(Host::table()->migration());
     $migrationManager->add(Tag::table()->migration());
     $migrationManager->add(Result::table()->migration());
     $migrationManager->add(Suite::table()->migration());
     $migrationManager->add(ResultTag::table()->migration());
     $migrationManager->add(Session::table()->migration());
     $migrationManager->add(Series::table()->migration());
     $migrationManager->add(SeriesTag::table()->migration());
     $migrationManager->run();
 }
Exemplo n.º 3
0
 public static function session()
 {
     $layout = new Layout();
     $id = $_GET['id'];
     if (!$id) {
         return self::notFound();
     }
     /** @var Session $session */
     $session = Session::find($id);
     if (!$session) {
         return self::notFound();
     }
     /** @var Tag[] $tags */
     $tags = Series::find()->select(Tag::columns())->leftJoin('? ON ? = ?', SeriesTag::table(), SeriesTag::columns()->seriesId, Series::columns()->id)->leftJoin('? ON ? = ?', Tag::table(), Tag::columns()->id, SeriesTag::columns()->tagId)->where('? = ?', Series::columns()->sessionId, $session->id)->groupBy(Tag::columns()->id)->bindResultClass(Tag::className())->query()->fetchAll();
     $layout->setList(new TagsFilter($tags));
     $layout->render();
     return true;
 }