Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed select grouping so that albums with the same name are listed #304

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions app/Controller/SongsController.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function albums() {
if ($page == 1) {
$latests = $this->Song->find('all', array(
'fields' => array('Song.id', 'Song.band', 'Song.album', 'Song.cover'),
'group' => 'Song.album',
'group' => array('Song.album', 'Song.band'),
'order' => 'Song.created DESC',
'limit' => 6
));
Expand All @@ -238,38 +238,27 @@ public function albums() {
$this->Paginator->settings = array(
'Song' => array(
'fields' => array('Song.id', 'Song.band', 'Song.album', 'Song.cover'),
'group' => 'Song.album',
'group' => array('Song.album', 'Song.band'),
'order' => $sort,
'limit' => 36
)
);
} else {
$subQuery = $db->buildStatement(
array(
'fields' => array('MIN(subsong.id)', 'subsong.album'),
'table' => $db->fullTableName($this->Song),
'alias' => 'subsong',
'group' => 'subsong.album'
),
$this->Song
);
$subQuery = ' (Song.id, Song.album) IN (' . $subQuery . ') ';

if ($page == 1) {
$latests = $this->Song->find('all', array(
'fields' => array('Song.id', 'Song.band', 'Song.album', 'Song.cover'),
'conditions' => $subQuery,
'fields' => array('MIN(Song.id)', 'Song.band', 'Song.album', 'Song.cover'),
'order' => 'Song.created DESC',
'group' => array('Song.album', 'Song.band'),
'limit' => 6
));
}

// This doesn't work on SQlite database
$this->Paginator->settings = array(
'Song' => array(
'fields' => array('Song.id', 'Song.band', 'Song.album', 'Song.cover'),
'conditions' => $subQuery,
'fields' => array('MIN(Song.id)', 'Song.band', 'Song.album', 'Song.cover', 'Song.album'),
'order' => $sort,
'group' => array('Song.album', 'Song.band'),
'limit' => 36
)
);
Expand Down