Skip to content

Commit

Permalink
Apply changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vithyze committed Mar 5, 2023
1 parent 8e2adf8 commit 57ee391
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions supysonic/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ def prune(cls):

class Track(PathMixin, _Model):
id = PrimaryKeyField()
disc = IntegerField()
number = IntegerField()
disc = IntegerField(null=True)
number = IntegerField(null=True)
title = CharField()
year = IntegerField(null=True)
genre = CharField(null=True)
Expand Down Expand Up @@ -350,15 +350,15 @@ def as_subsonic_child(self, user, prefs):
"title": self.title,
"album": self.album.name,
"artist": self.artist.name,
"track": self.number,
"track": self.number or "",
"size": os.path.getsize(self.path) if os.path.isfile(self.path) else -1,
"contentType": self.mimetype,
"suffix": self.suffix(),
"duration": self.duration,
"bitRate": self.bitrate,
"path": self.path[len(self.root_folder.path) + 1 :],
"isVideo": False,
"discNumber": self.disc,
"discNumber": self.disc or "",
"created": self.created.isoformat(),
"albumId": str(self.album.id),
"artistId": str(self.artist.id),
Expand Down Expand Up @@ -421,7 +421,7 @@ def suffix(self):
return os.path.splitext(self.path)[1][1:].lower()

def sort_key(self):
return f"{self.album.artist.name}{self.album.name}{self.disc:02}{self.number:02}{self.title}".lower()
return f"{self.album.artist.name}{self.album.name}{self.disc:02 or ''}{self.number:02 or ''}{self.title}".lower()


class User(_Model):
Expand Down
4 changes: 2 additions & 2 deletions supysonic/schema/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ CREATE INDEX index_album_artist_id_fk ON album(artist_id);

CREATE TABLE IF NOT EXISTS track (
id CHAR(32) PRIMARY KEY,
disc INTEGER NOT NULL,
number INTEGER NOT NULL,
disc INTEGER,
number INTEGER,
title VARCHAR(256) NOT NULL,
year INTEGER,
genre VARCHAR(256),
Expand Down
4 changes: 2 additions & 2 deletions supysonic/schema/postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ CREATE INDEX IF NOT EXISTS index_album_artist_id_fk ON album(artist_id);

CREATE TABLE IF NOT EXISTS track (
id UUID PRIMARY KEY,
disc INTEGER NOT NULL,
number INTEGER NOT NULL,
disc INTEGER,
number INTEGER,
title CITEXT NOT NULL,
year INTEGER,
genre VARCHAR(256),
Expand Down
4 changes: 2 additions & 2 deletions supysonic/schema/sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ CREATE INDEX IF NOT EXISTS index_album_artist_id_fk ON album(artist_id);

CREATE TABLE IF NOT EXISTS track (
id CHAR(36) PRIMARY KEY,
disc INTEGER NOT NULL,
number INTEGER NOT NULL,
disc INTEGER,
number INTEGER,
title VARCHAR(256) NOT NULL COLLATE NOCASE,
year INTEGER,
genre VARCHAR(256),
Expand Down

0 comments on commit 57ee391

Please sign in to comment.