1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 00:24:12 +02:00

[0.9 api]Implement albums view for collections

This commit is contained in:
Anton Romanov
2015-09-11 14:00:29 -07:00
parent 079f793b74
commit 46bbe7ac74

View File

@@ -1282,7 +1282,6 @@ Tomahawk.Collection = {
{
var map = that.statements[originalI].map;
that.results[originalI] = [];
Tomahawk.log('originalI ' + originalI);
for (var ii = 0; ii < results.rows.length; ii++) {
that.results[originalI].push(map(
results.rows.item(ii)
@@ -1295,7 +1294,6 @@ Tomahawk.Collection = {
if(that.stmtsToResolve == 0)
{
that.statements = [];
Tomahawk.log(JSON.stringify(that.results));
resolve(that.results);
}
};
@@ -1695,40 +1693,43 @@ Tomahawk.Collection = {
});
},
//albums: function (params, where) {
////TODO filter/where support
//var id = params.id;
//if(typeof id === 'undefined')
//id = this.settings.id;
albums: function (params, where) {
//TODO filter/where support
var id = params.id;
if(typeof id === 'undefined')
id = this.settings.id;
//var t = new Tomahawk.Collection.Transaction(this, id);
//return t.beginTransaction().then(function () {
//var mapFn = function(row) {
//return {
//albumArtist: row.artist,
//albumArtistDisambiguation: row.artistDisambiguation,
//album: row.album
//};
//};
//t.sqlSelect("albums",mapFn,
//["album", "artist", "artistDisambiguation"],
//where, [
//{
//table: "artists",
//conditions: {
//albumArtistId: "_id"
//}
//}
//]
//);
//return t.execDefferedStatements();
//}).then(function (results) {
//return {
//artists: results[0].map(function(i){ return i.albumArtist;}),
//albums: results[0].map(function(i){ return i.album;})
//};
//});
//},
var t = new Tomahawk.Collection.Transaction(this, id);
return t.beginTransaction().then(function () {
var mapFn = function(row) {
return {
albumArtist: row.artist,
albumArtistDisambiguation: row.artistDisambiguation,
album: row.album
};
};
t.sqlSelect("albums",mapFn,
["album", "artist", "artistDisambiguation"],
where, [
{
table: "artists",
conditions: {
albumArtistId: "_id"
}
}
]
);
return t.execDefferedStatements();
}).then(function (results) {
results = results[0].filter(function(e){
return (e.albumArtist != '' && e.album != '');
});
return {
artists: results.map(function(i){ return i.albumArtist;}),
albums: results.map(function(i){ return i.album;})
};
});
},
artists: function (params) {
//TODO filter/where support