Ejemplo n.º 1
0
 public function performAction()
 {
     $project = new Project();
     $project->name = $this->name;
     $project->apiKey = $this->apiKey;
     $project->description = $this->description;
     $project->save();
     $this->response->success('Project ID ' . $project->id . ' created');
 }
Ejemplo n.º 2
0
 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());
     }
 }
Ejemplo n.º 3
0
 /**
  * Required setup column types in provided columns object
  * @param $columns static|\stdClass
  */
 static function setUpColumns($columns)
 {
     $columns->id = Column::AUTO_ID;
     $columns->tagIds = Column::create(Column::STRING + Column::NOT_NULL)->setDefault('')->setUnique();
     $columns->projectId = Column::cast(Project::columns()->id)->copy()->setFlag(Column::NOT_NULL, false);
     $columns->lastSeen = Column::INTEGER + Column::TIMESTAMP;
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 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();
     }
 }