Example #1
0
 public static function roomsList()
 {
     /** @var Collection $collection */
     $collection = \Yii::$app->get('mongodb')->getCollection(Participant::collectionName());
     $cursor = $collection->find(['confirmPersonId' => \Yii::$app->user->identity['_id']], ['name' => 1]);
     $rooms = [];
     foreach ($cursor as $document) {
         $rooms[(string) $document['_id']] = $document['name'];
     }
     return $rooms;
 }
Example #2
0
 public function getRoomApproveList()
 {
     /** @var Collection $collection */
     $collection = \Yii::$app->get('mongodb')->getCollection(Participant::collectionName());
     $list = $collection->aggregate([['$match' => ['confirmPersonId' => $this->_id, 'log.status' => Participant::STATUS_CONSIDIRATION]], ['$unwind' => '$log'], ['$match' => ['log.status' => Participant::STATUS_CONSIDIRATION]], ['$project' => ['name' => 1, 'request' => '$log.requestId']]]);
     foreach ($list as $key => $value) {
         $list[$key]['request'] = VksRequest::findOne(['_id' => $value['request']]);
     }
     return $list;
 }
Example #3
0
 /**
  * @param \MongoId $roomId
  * @return string
  * @throws \yii\base\InvalidConfigException
  * @throws \yii\mongodb\Exception
  */
 public function getRoomStatus(\MongoId $roomId)
 {
     if ($this->_roomsStatus === null) {
         /** @var Collection $collection */
         $collection = \Yii::$app->get('mongodb')->getCollection(Participant::collectionName());
         $pipeline = [['$unwind' => '$log'], ['$match' => ['log.requestId' => $this->_id]], ['$project' => ['status' => '$log.status']]];
         $this->_roomsStatus = ArrayHelper::map($collection->aggregate($pipeline), function ($item) {
             return (string) $item['_id'];
         }, 'status');
     }
     return $this->_roomsStatus[(string) $roomId];
 }