public function testSetTags() { $tagGroup = new TagGroup(); $tagGroup->setTags(array('tag1', 'tag2', 'tag3')); $tagGroup->save(); $this->assertEquals(array('tag1', 'tag2', 'tag3'), Tag::statement()->where('? IN (?)', Tag::columns()->id, new Raw(TagGroup::findByPrimaryKey($tagGroup->id)->tagIds))->query()->fetchAll(null, Tag::columns()->text)); }
private function addData($filename, $content) { try { if (null === $this->runInstance) { $this->runInstance = new Run(); $this->runInstance->ut = time(); $this->runInstance->name = $this->alias; $this->runInstance->save(); if ($this->project) { $project = new Project(); $project->name = $this->project; $project->findOrSave(); $this->runInstance->projectId = $project->id; } if ($this->tags) { $tagGroup = new TagGroup(); $tagGroup->setTags($this->tags); $tagGroup->projectId = $this->runInstance->projectId; $tagGroup->findOrSave(); $this->runInstance->tagGroupId = $tagGroup->id; $this->runInstance->save(); } } ++$this->index; Console::getInstance()->returnCaret()->printF(new Expression('?% ? ?', round(100 * ($this->index / $this->count)), $this->index, $filename)); $xhprofData = unserialize($content); if (!is_array($xhprofData)) { $this->response->error(new Expression("Can not unserialize ?", $filename)); return; } $nameString = new Parser($filename); $ut = floor((string) $nameString->inner('_', '.serialized', true)); $run = $this->runInstance; if ($run->findSaved() && $this->noSquash) { Console::getInstance()->printLine(" already imported"); return; } //xhprof_enable(); $this->addRun($xhprofData, $run); //$data = xhprof_disable(); //$xhFilename = '/tmp/xhprof/import' . '_' . microtime(1) . '.serialized'; //file_put_contents($xhFilename, serialize($data)); } catch (Exception $exception) { Console::getInstance()->eol(); print_r($this->lastSample); Console::getInstance()->printLine($exception->query); $this->response->error($exception->getMessage()); } }
/** * Required setup column types in provided columns object * @param $columns static|\stdClass */ static function setUpColumns($columns) { $columns->id = Column::AUTO_ID; $columns->runId = Run::columns()->id; $columns->tagGroupId = TagGroup::columns()->id; $columns->period = Column::INTEGER + Column::NOT_NULL; $columns->utFrom = Column::INTEGER + Column::TIMESTAMP; $columns->utTo = Column::INTEGER + Column::TIMESTAMP; }
static function setUpColumns($columns) { $columns->id = Column::AUTO_ID; $columns->ut = Column::TIMESTAMP + Column::INTEGER; $columns->runs = Column::create(Column::INTEGER + Column::NOT_NULL)->setDefault(0); $columns->name = Column::STRING; $columns->projectId = Column::cast(Project::columns()->id)->copy()->setFlag(Column::NOT_NULL, false); $columns->tagGroupId = Column::cast(TagGroup::columns()->id)->copy()->setFlag(Column::NOT_NULL, false); parent::setUpColumns($columns); }
public function run(Log $log = null) { /** @var \Yaoi\Database\Definition\Table[] $tables */ $tables = array(Symbol::table(), Run::table(), RelatedStat::table(), SymbolStat::table(), Project::table(), Tag::table(), Aggregate::table(), ReportAggregate::table(), TagGroup::table()); if (null === $log) { $log = Log::nil(); } foreach ($tables as $table) { $table->migration()->setLog($log)->apply(); } }