Example #1
0
 /**
  * Browse Service
  * 
  * @param KCommandContext $context
  */
 protected function _actionBrowse(KCommandContext $context)
 {
     if (!$context->query) {
         $context->query = $this->getRepository()->getQuery();
     }
     $query = $context->query;
     $query->select('COUNT(*) AS count')->join('RIGHT', 'anahita_edges AS edge', 'hashtag.id = edge.node_a_id')->order('count', 'DESC')->limit($this->limit, $this->start);
     if ($this->sort == 'trending') {
         $now = new KDate();
         $query->where('edge.created_on', '>', $now->addDays(-(int) $this->days)->getDate());
     }
     return $this->getState()->setList($query->toEntityset())->getList();
 }
Example #2
0
 /**
  * Browse Service.
  *
  * @param KCommandContext $context
  */
 protected function _actionBrowse(KCommandContext $context)
 {
     $entities = parent::_actionBrowse($context);
     if (in_array($this->sort, array('top', 'trending')) && $this->q == '') {
         $package = $this->getIdentifier()->package;
         $name = $this->getIdentifier()->name;
         $entities->select('COUNT(*) AS count')->join('RIGHT', 'edges AS edge', $name . '.id = edge.node_a_id')->where('edge.type', 'LIKE', '%com:' . $package . '.domain.entity.tag')->group($name . '.id')->order('count', 'DESC');
         if ($this->sort == 'trending') {
             $now = new KDate();
             $entities->where('edge.created_on', '>', $now->addDays(-(int) $this->days)->getDate());
         }
     }
     return $entities;
 }