Beispiel #1
0
 public function actionTest()
 {
     $list = Tweet::find()->all();
     foreach ($list as $twit) {
         $twit->saveIndex();
     }
 }
 public function actionViewUser($username)
 {
     $query = Tweet::find()->where(['owner' => $username])->orderBy('timestamp DESC');
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $tweets = $query->offset($pages->offset)->limit($pages->limit)->all();
     return $this->render('gridview', ['tweets' => $tweets, 'pages' => $pages]);
 }
function getNumTweetsForIntervalByUsername($username, $startMonth, $startYear, $endMonth, $endYear)
{
    $startOfInterval = getStartOfMonth($startMonth, $startYear);
    $endOfInterval = getEndOfMonth($endMonth, $endYear);
    return Tweet::find()->where(['between', 'timestamp', $startOfInterval, $endOfInterval])->andWhere(['owner' => $username])->count();
}
Beispiel #4
0
 /**
  * @param $fromDateTime
  * @param $toDateTime
  *
  * @return Tweet[]
  */
 private function getTweets($fromDateTime, $toDateTime)
 {
     $tweets = Tweet::find()->byDate($fromDateTime, $toDateTime)->hashtagsViaJunctionTable()->all();
     return $tweets;
 }
 /**
  * Deletes an existing Tweet model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param string $id
  * @return mixed
  */
 public function actionValidate()
 {
     $dataProvider = new ActiveDataProvider(['query' => Tweet::find()->where(['needs_validation' => 1, 'old_vote' => 0])]);
     return $this->render('validate', ['dataProvider' => $dataProvider]);
 }
Beispiel #6
0
 /**
  * @param int $count
  *
  * @return array
  */
 public function findLastTweets($count)
 {
     $lastTweets = Tweet::find()->byLastOnes($count)->hashtagsViaJunctionTable()->all();
     return $this->composeTweetsForJSON($lastTweets);
 }
Beispiel #7
0
            <?php 
$ratings = Tweet::find()->select(['COUNT(*) AS rating_count', 'rating'])->where(['entry_id' => $model->id, 'needs_validation' => 0])->groupBy(['rating'])->asArray()->all();
$chart_labels = [];
$chart_values = [];
foreach ($ratings as $elem) {
    $chart_labels[] = $elem['rating'];
    $chart_values[] = $elem['rating_count'];
}
?>
            <?php 
echo ChartJs::widget(['type' => 'Bar', 'options' => ['height' => 250], 'clientOptions' => ['responsive' => true, 'maintainAspectRatio' => false], 'data' => ['labels' => $chart_labels, 'datasets' => [['label' => "My Second dataset", 'fillColor' => "rgba(151,187,205,0.5)", 'strokeColor' => "rgba(151,187,205,1)", 'pointColor' => "rgba(151,187,205,1)", 'pointStrokeColor' => "#fff", 'data' => $chart_values]]]]);
?>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-lg-12">
        <h2><?php 
echo Yii::t('app', 'Tweets');
?>
</h2>
        <?php 
Pjax::begin(['id' => 'tweet-grid']);
echo GridView::widget(['dataProvider' => new ActiveDataProvider(['query' => Tweet::find()->where(['entry_id' => $model->id, 'needs_validation' => 0, 'old_vote' => 0])]), 'columns' => [['attribute' => 'user.screen_name', 'value' => function ($data) {
    return $data->user->screen_name;
}], 'rating', ['attribute' => 'text', 'contentOptions' => ['class' => 'hidden-xs'], 'headerOptions' => ['class' => 'hidden-xs']], ['label' => Yii::t('app', 'Tweeted at'), 'attribute' => 'created_at', 'format' => ['datetime', 'php:d.m.Y - H:i:s'], 'contentOptions' => ['class' => 'hidden-xs'], 'headerOptions' => ['class' => 'hidden-xs']]]]);
Pjax::end();
?>
    </div>
</div>