Exemplo n.º 1
0
 /**
  * Output window.titles
  */
 public function actionTitles()
 {
     $titles = Window::find()->select(['title'])->distinct(true)->orderBy('title')->createCommand()->queryAll();
     array_walk(array_filter($titles, function ($a) {
         return trim($a['title']) != '';
     }), function ($a) {
         echo trim($a['title']) . PHP_EOL;
     });
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Window::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'process_id' => $this->process_id, 'created' => $this->created]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'class', $this->class]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 public function clusterChart($searchModel)
 {
     $from = strtotime('today', $searchModel->timestampFrom);
     $to = strtotime('tomorrow', $searchModel->timestampTo);
     $query = Window::find()->select(['title'])->joinWith('records')->distinct(true)->orderBy('title');
     StatsHelper::whereFromTo($query, $from, $to);
     $titles = $query->createCommand()->queryColumn();
     $titles = array_filter($titles, function ($a) {
         return trim($a) != '';
     });
     $clusters = ClusterHelper::clusterizeStrings($titles);
     $clustersList = array_map(function ($a) {
         return ['id' => $a, 'name' => $a];
     }, array_unique(array_values($clusters)));
     $this->view->registerJs('var dashboardClusters = ' . json_encode($clustersList), View::POS_HEAD);
     $durations = ClusterHelper::getProcessWindowHierarchy($clusters, $from, $to);
     $this->view->registerJs('var dashboardClustersDurations = ' . json_encode($durations), View::POS_HEAD);
     $this->view->registerAssetBundle(SunburstAsset::className());
 }
Exemplo n.º 4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $this->load($params);
     $query = Window::find()->joinWith('records', false)->select(['{{window}}.*', 'SUM(duration) as time', 'SUM(motions) as motions', 'SUM(motions_filtered) as motions_filtered', 'SUM(clicks) as clicks', 'SUM(scrolls) as scrolls', 'SUM(keys) as keys']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['attributes' => ['time'], 'defaultOrder' => ['time' => SORT_DESC]]]);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->groupBy('{{window}}.' . $this->groupBy);
     $query->andFilterWhere(['created' => $this->created]);
     $timezone = new \DateTimeZone(\Yii::$app->timeZone);
     if ($this->timestamp) {
         $from = (new \DateTime('@' . strtotime('today', $this->timestamp)))->setTimezone($timezone);
         $query->andWhere('{{record}}.start >= :today', [':today' => $from->format('Y-m-d H:i:s')]);
     }
     if ($this->timestamp) {
         $to = (new \DateTime('@' . strtotime('tomorrow', $this->timestamp)))->setTimezone($timezone);
         $query->andWhere('{{record}}.start < :todayNight', [':todayNight' => $to->format('Y-m-d H:i:s')]);
     }
     return $dataProvider;
 }
Exemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getWindow()
 {
     return $this->hasOne(Window::className(), ['id' => 'window_id'])->inverseOf('records');
 }
Exemplo n.º 6
0
 /**
  * Finds the Window model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Window the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Window::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 7
0
 public function getWindows()
 {
     return $this->hasMany(Window::className(), ['process_id' => 'id']);
 }