Skip to content

Commit

Permalink
ignore case when ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-klein committed Apr 18, 2018
1 parent e845645 commit 37a9d8e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions resources/lib/database_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ def get_content_items(self, status, mediatype=None):
if mediatype:
self.c.execute(
"SELECT * FROM Content WHERE Status=? AND Mediatype=? \
ORDER BY (CASE WHEN Title LIKE 'the %' THEN substr(Title,5) ELSE Title END)",
ORDER BY (CASE WHEN Title LIKE 'the %' THEN substr(Title,5) \
ELSE Title END) COLLATE NOCASE",
(status, mediatype))
else:
self.c.execute(
"SELECT * FROM Content WHERE Status=? \
ORDER BY (CASE WHEN Title LIKE 'the %' THEN substr(Title,5) ELSE Title END)",
ORDER BY (CASE WHEN Title LIKE 'the %' THEN substr(Title,5) \
ELSE Title END) COLLATE NOCASE",
(status,))
# get results and return items as objects
rows = self.c.fetchall()
Expand All @@ -70,7 +72,8 @@ def get_all_shows(self, status):
# query database
self.c.execute(
"SELECT DISTINCT Show_Title FROM Content WHERE Status=? \
ORDER BY (CASE WHEN Show_Title LIKE 'the %' THEN substr(Show_Title,5) ELSE Show_Title END)",
ORDER BY (CASE WHEN Show_Title LIKE 'the %' THEN substr(Show_Title,5) \
ELSE Show_Title END) COLLATE NOCASE",
(status,))
# get results and return items as list
rows = self.c.fetchall()
Expand All @@ -83,7 +86,8 @@ def get_show_episodes(self, status, show_title):
# query database
self.c.execute(
"SELECT * FROM Content WHERE Status=? AND Show_Title=?\
ORDER BY (CASE WHEN Title LIKE 'the %' THEN substr(Title,5) ELSE Title END)",
ORDER BY (CASE WHEN Title LIKE 'the %' THEN substr(Title,5) \
ELSE Title END) COLLATE NOCASE",
(status, show_title))
# get results and return items as objects
rows = self.c.fetchall()
Expand Down Expand Up @@ -196,7 +200,8 @@ def get_synced_dirs(self):
# query database
self.c.execute(
"SELECT * FROM Synced \
ORDER BY (CASE WHEN Label LIKE 'the %' THEN substr(Label,5) ELSE Label END)")
ORDER BY (CASE WHEN Label LIKE 'the %' THEN substr(Label,5) \
ELSE Label END) COLLATE NOCASE")
# get results and return as list of dicts
rows = self.c.fetchall()
return [self.synced_item_dict(x) for x in rows]
Expand Down Expand Up @@ -232,7 +237,7 @@ def remove_all_synced_dirs(self):
def get_blocked_items(self):
''' Returns all items in Blocked as a list of dicts '''
self.c.execute(
"SELECT * FROM Blocked ORDER BY Value, Type")
"SELECT * FROM Blocked ORDER BY Type, Value")
rows = self.c.fetchall()
return [self.blocked_item_dict(x) for x in rows]

Expand Down

0 comments on commit 37a9d8e

Please sign in to comment.