diff options
author | Michaël Ball <michael.ball@gmail.com> | 2014-12-28 12:24:22 +0000 |
---|---|---|
committer | Michaël Ball <michael.ball@gmail.com> | 2015-11-27 20:02:04 +0000 |
commit | 75beec91a8526fbbc0a90134140b9dff6af15c0c (patch) | |
tree | 02414e46da3e08000384c40c27b7aab9748de0fe /models/track.py | |
parent | a2964845e3c03b9cf5f01583f53f7553c7d67caf (diff) |
Initial frontend work
Diffstat (limited to 'models/track.py')
-rw-r--r-- | models/track.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/models/track.py b/models/track.py index dead1f8..688f6ff 100644 --- a/models/track.py +++ b/models/track.py @@ -361,7 +361,7 @@ class Track: for artist_name in artist_names: musicbrainz_artistid = None - artistsort = None + artistsort = artist_name try: musicbrainz_artistid = musicbrainz_artist_ids[i] except IndexError: @@ -543,3 +543,28 @@ class Track: db.commit() return True + + def all(order="track.id", direction="ASC", limit=None, offset=None): + db = DbManager() + tracks = [] + + select_string = """SELECT * FROM track LEFT JOIN artist_track ON + artist_track.track_id = track.id LEFT JOIN artist ON + artist_track.artist_id = artist.id LEFT JOIN album_track ON + album_track.track_id = track.id LEFT JOIN album ON + album_track.album_id = album.id ORDER BY %s %s""" % (order, + direction) + + if limit is not None and offset is not None: + select_string = " ".join((select_string, + "LIMIT %s OFFSET %s" % (limit, offset))) + + result = db.execute(select_string) + + for row in result: + tracks.append( + Track(id=row[0], tracknumber=row[1], name=row[3], + grouping=row[3], filename=row[4]) + ) + + return tracks |