123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace app\controllers;
- use Yii;
- use yii\filters\AccessControl;
- use yii\web\Controller;
- use yii\web\Response;
- use yii\filters\VerbFilter;
- use app\lib\GA;
- use app\models\ContentPage;
- class IndexController extends Controller
- {
-
-
- public function actionIndex(){
- echo 111;exit;
- }
- public function actionContentpage(){
- $pages=ContentPage::find()->asArray()->all();
- \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
- return [
- 'code' => 200,
- 'data'=>$pages,
- 'status'=>true
- ];
- }
- public function actionSynsdata(){
- $ga=new GA();
- $store="supernova";
- $contentpages=$ga->contentpages($store);
- $i=1;
- $limit=20;
- $modelKey=[
- 'pagePath',
- 'store',
- 'date',
- 'pageviews',
- 'uniquePageviews',
- 'avgTimeOnPage',
- 'entrances',
- 'bounceRate',
- 'exitRate',
- 'pageValue',
- 'created_at',
- ];
- if(!empty($contentpages)){
- $list=[];
- foreach($contentpages as $k=>$v){
- $item=[
- $v['pagePath'],
- $store,
- date('y-m-d',strtotime($v['date'])),
- $v['pageviews'],
- $v['uniquePageviews'],
- $v['avgTimeOnPage'],
- $v['entrances'],
- $v['bounceRate'],
- $v['exitRate'],
- $v['pageValue'],
- time(),
- ];
- $list[]=$item;
- if($i%$limit==0||$i==count($contentpages)){
- \Yii::$app->db->createCommand()->batchInsert(ContentPage::tableName(), $modelKey, $list)->execute();
- $list=[];
- echo 111111;exit;
- }
- $i++;
- }
- }
- echo 111111;exit;
- }
-
|