Ejemplo n.º 1
0
Archivo: Wrap.php Proyecto: apuc/api
 public static function getStat()
 {
     $wrap = new Wrap();
     $wrap->done_wrap_vk = Wrap::find()->where(['>', 'date', mktime(strftime('-1 day', time()))])->sum('done_wrap_vk');
     $wrap->like_wrap_vk = Wrap::find()->where(['>', 'date', mktime(strftime('-1 day', time()))])->sum('like_wrap_vk');
     $wrap->repost_wrap_vk = Wrap::find()->where(['>', 'date', mktime(strftime('-1 day', time()))])->sum('repost_wrap_vk');
     $wrap->subscriber_wrap_vk = Wrap::find()->where(['>', 'date', mktime(strftime('-1 day', time()))])->sum('subscriber_wrap_vk');
     return $wrap;
 }
Ejemplo n.º 2
0
 public function actionGet()
 {
     //todo поправить костыль
     $done = Order::find(['status' => [Order::DONE, Order::DONE_AND_HIDE]])->count();
     $like = StatisticsMenu::getCount(1);
     $subscriber = StatisticsMenu::getCount(3);
     $repost = StatisticsMenu::getCount(4);
     $wrap = Wrap::getStat();
     $data['stat_done_vk'] = $done + $wrap->done_wrap_vk;
     $data['stat_like_vk'] = $like + $wrap->like_wrap_vk;
     $data['stat_repost_vk'] = $repost + $wrap->repost_wrap_vk;
     $data['stat_subscriber_vk'] = $subscriber + $wrap->subscriber_wrap_vk;
     echo json_encode($data);
 }
Ejemplo n.º 3
0
 /**
  * @var Wrap $wrap
  * @return string
  * @throws \Exception
  */
 public function run()
 {
     if (!\Yii::$app->cache->exists('wrap')) {
         Wrap::addWrap();
         \Yii::$app->cache->set('wrap', 0, rand(30, 70));
     }
     $wrap = Wrap::getStat();
     $done = Order::find(['status' => [Order::DONE, Order::DONE_AND_HIDE]])->count();
     $like = self::getCount(1);
     $subscriber = self::getCount(3);
     $repost = self::getCount(4);
     $done += $wrap->done_wrap_vk;
     $like += $wrap->like_wrap_vk;
     $repost += $wrap->repost_wrap_vk;
     $subscriber += $wrap->subscriber_wrap_vk;
     return $this->render('menu', ['done' => isset($done) ? $done : 0, 'like' => isset($like) ? $like : 0, 'repost' => isset($repost) ? $repost : 0, 'subscriber' => isset($subscriber) ? $subscriber : 0]);
 }