public function votesAction() { $threshold = strtotime('-2 weeks'); $votes_raw = $this->em->createQuery('SELECT sv.song_id, SUM(sv.vote) AS vote_total FROM Entity\\SongVote sv WHERE sv.station_id = :station_id AND sv.timestamp >= :threshold GROUP BY sv.song_id')->setParameter('station_id', $this->station->id)->setParameter('threshold', $threshold)->getArrayResult(); $ignored_songs = $this->_getIgnoredSongs(); $votes_raw = array_filter($votes_raw, function ($value) use($ignored_songs) { return !isset($ignored_songs[$value['song_id']]); }); \PVL\Utilities::orderBy($votes_raw, 'vote_total DESC'); $votes = array(); foreach ($votes_raw as $row) { $row['song'] = Song::find($row['song_id']); $votes[] = $row; } $this->view->votes = $votes; }
public function votesAction() { $threshold = strtotime('-1 week'); $votes_raw = $this->em->createQuery('SELECT sv.song_id, SUM(sv.vote) AS vote_total FROM Entity\\SongVote sv WHERE sv.timestamp >= :threshold GROUP BY sv.song_id')->setParameter('threshold', $threshold)->getArrayResult(); Utilities::orderBy($votes_raw, 'vote_total DESC'); $votes = array(); foreach ($votes_raw as $row) { $row['song'] = Song::find($row['song_id']); $votes[] = $row; } $this->view->votes = $votes; }