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

Draft PostgreSQL support #3232

Draft
wants to merge 17 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@ _ReSharper*/
.vscode

# Python virtual env
venv
venv

# Ctags
tags
12 changes: 6 additions & 6 deletions data/interfaces/default/album.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
<div id="dialog" title="Choose an Alternate Release" style="display:none" class="configtable">
<div class="links">
<%
alternate_albums = myDB.select("SELECT * from allalbums WHERE AlbumID=? ORDER BY ReleaseDate ASC", [album['AlbumID']])
alternate_albums = myDB.select("SELECT * from allalbums WHERE AlbumID=%s ORDER BY ReleaseDate ASC", [album['AlbumID']])
%>
%if not alternate_albums:
<p>No alternate releases found. Try refreshing the artist (if the artist is being refreshed, please wait until it's finished)</p>
<h2><a id="refresh_artist" onclick="doAjaxCall('refreshArtist?ArtistID=${album['ArtistID']}', $(this)), true" href="javascript:void(0)" data-success="'${album['ArtistName']}' is being refreshed">Refresh Artist</a></h2>
%else:
%for alternate_album in alternate_albums:
<%
track_count = len(myDB.select("SELECT * from alltracks WHERE ReleaseID=?", [alternate_album['ReleaseID']]))
track_count = len(myDB.select("SELECT * from alltracks WHERE ReleaseID=%s", [alternate_album['ReleaseID']]))
mb_link = "http://musicbrainz.org/release/" + alternate_album['ReleaseID']
have_track_count = len(myDB.select("SELECT * from alltracks WHERE ReleaseID=? AND Location IS NOT NULL", [alternate_album['ReleaseID']]))
have_track_count = len(myDB.select("SELECT * from alltracks WHERE ReleaseID=%s AND Location IS NOT NULL", [alternate_album['ReleaseID']]))
if alternate_album['AlbumID'] == alternate_album['ReleaseID']:
alternate_album_name = "Headphones Default Release (" + str(alternate_album['ReleaseDate']) + ") [" + str(have_track_count) + "/" + str(track_count) + " tracks]"
else:
Expand Down Expand Up @@ -100,8 +100,8 @@ <h2 id="artistname">
</h2>

<%
totalduration = myDB.action("SELECT SUM(TrackDuration) FROM tracks WHERE AlbumID=?", [album['AlbumID']]).fetchone()[0]
totaltracks = len(myDB.select("SELECT TrackTitle from tracks WHERE AlbumID=?", [album['AlbumID']]))
totalduration = myDB.action("SELECT SUM(TrackDuration) as totalduration FROM tracks WHERE AlbumID=%s", [album['AlbumID']]).fetchone()['totalduration']
totaltracks = len(myDB.select("SELECT TrackTitle from tracks WHERE AlbumID=%s", [album['AlbumID']]))
try:
albumduration = helpers.convert_milliseconds(totalduration)
except:
Expand Down Expand Up @@ -163,7 +163,7 @@ <h2 id="artistname">
</tr>
%endfor
<%
unmatched = myDB.select('SELECT * from have WHERE ArtistName LIKE ? AND AlbumTitle LIKE ? AND Matched = "Failed" ORDER BY CAST(TrackNumber AS INTEGER)', [album['ArtistName'], album['AlbumTitle']])
unmatched = myDB.select('SELECT * from have WHERE ArtistName LIKE %s AND AlbumTitle LIKE %s AND Matched = %s ORDER BY CAST(TrackNumber AS INTEGER)', [album['ArtistName'], album['AlbumTitle'], 'Failed'])
%>
%if unmatched:
%for track in unmatched:
Expand Down
10 changes: 5 additions & 5 deletions data/interfaces/default/artist.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ <h1 id="artistname">
grade = 'A'

myDB = db.DBConnection()
totaltracks = len(myDB.select('SELECT TrackTitle from tracks WHERE AlbumID=?', [album['AlbumID']]))
havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE AlbumID=? AND Location IS NOT NULL', [album['AlbumID']])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ? AND AlbumTitle LIKE ? AND Matched = "Failed"', [album['ArtistName'], album['AlbumTitle']]))
totaltracks = len(myDB.select('SELECT TrackTitle from tracks WHERE AlbumID=%s', [album['AlbumID']]))
havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE AlbumID=%s AND Location IS NOT NULL', [album['AlbumID']])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like %s AND AlbumTitle LIKE %s AND Matched = %s', [album['ArtistName'], album['AlbumTitle'], 'Failed']))

try:
percent = (havetracks*100.0)/totaltracks
Expand All @@ -103,15 +103,15 @@ <h1 id="artistname">
percent = 0
totaltracks = '?'

avgbitrate = myDB.action("SELECT AVG(BitRate) FROM tracks WHERE AlbumID=?", [album['AlbumID']]).fetchone()[0]
avgbitrate = myDB.action("SELECT AVG(BitRate) FROM tracks WHERE AlbumID=%s", [album['AlbumID']]).fetchone()[0]
if avgbitrate:
bitrate = str(int(avgbitrate)/1000) + ' kbps'
else:
bitrate = ''

albumformatcount = myDB.action("SELECT COUNT(DISTINCT Format) FROM tracks WHERE AlbumID=?", [album['AlbumID']]).fetchone()[0]
albumformatcount = myDB.action("SELECT COUNT(DISTINCT Format) FROM tracks WHERE AlbumID=%s", [album['AlbumID']]).fetchone()[0]
if albumformatcount == 1:
albumformat = myDB.action("SELECT DISTINCT Format FROM tracks WHERE AlbumID=?", [album['AlbumID']]).fetchone()[0]
albumformat = myDB.action("SELECT DISTINCT Format FROM tracks WHERE AlbumID=%s", [album['AlbumID']]).fetchone()[0]
elif albumformatcount > 1:
albumformat = 'Mixed'
else:
Expand Down
10 changes: 5 additions & 5 deletions data/interfaces/default/managealbums.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ <h1 class="clearfix"><i class="fa fa-music"></i> Manage Albums</h1>
grade = 'A'

myDB = db.DBConnection()
totaltracks = len(myDB.select('SELECT TrackTitle from tracks WHERE AlbumID=?', [album['AlbumID']]))
havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE AlbumID=? AND Location IS NOT NULL', [album['AlbumID']])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ? AND AlbumTitle LIKE ? AND Matched = "Failed"', [album['ArtistName'], album['AlbumTitle']]))
totaltracks = len(myDB.select('SELECT TrackTitle from tracks WHERE AlbumID=%s', [album['AlbumID']]))
havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE AlbumID=%s AND Location IS NOT NULL', [album['AlbumID']])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like %s AND AlbumTitle LIKE %s AND Matched = %s', [album['ArtistName'], album['AlbumTitle'], 'Failed']))

try:
percent = (havetracks*100.0)/totaltracks
Expand All @@ -70,15 +70,15 @@ <h1 class="clearfix"><i class="fa fa-music"></i> Manage Albums</h1>
percent = 0
totaltracks = '?'

avgbitrate = myDB.action("SELECT AVG(BitRate) FROM tracks WHERE AlbumID=?", [album['AlbumID']]).fetchone()[0]
avgbitrate = myDB.action("SELECT AVG(BitRate) FROM tracks WHERE AlbumID=%s", [album['AlbumID']]).fetchone()[0]
if avgbitrate:
bitrate = str(int(avgbitrate)/1000) + ' kbps'
else:
bitrate = ''

albumformatcount = myDB.action("SELECT COUNT(DISTINCT Format) FROM tracks WHERE AlbumID=?", [album['AlbumID']]).fetchone()[0]
albumformatcount = myDB.action("SELECT COUNT(DISTINCT Format) FROM tracks WHERE AlbumID=%s", [album['AlbumID']]).fetchone()[0]
if albumformatcount == 1:
albumformat = myDB.action("SELECT DISTINCT Format FROM tracks WHERE AlbumID=?", [album['AlbumID']]).fetchone()[0]
albumformat = myDB.action("SELECT DISTINCT Format FROM tracks WHERE AlbumID=%s", [album['AlbumID']]).fetchone()[0]
elif albumformatcount > 1:
albumformat = 'Mixed'
else:
Expand Down
2 changes: 1 addition & 1 deletion data/interfaces/default/manageunmatched.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
myDB = db.DBConnection()
artist_json = {}
counter = 0
artist_list = myDB.action("SELECT ArtistName from artists ORDER BY ArtistName COLLATE NOCASE")
artist_list = myDB.action("SELECT ArtistName from artists ORDER BY lower(ArtistName)")
for artist in artist_list:
artist_json[counter] = artist['ArtistName']
counter+=1
Expand Down
Loading