From 3f1ddd6489427fc24820250563899fe6227d065b Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 20 Aug 2012 16:53:39 +0530 Subject: [PATCH 1/4] Don't try to load the artist page until it has the bare minimum info needed to render it --- headphones/webserve.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 7e905a24..c1d6674b 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -62,6 +62,20 @@ class WebInterface(object): artist = myDB.action('SELECT * FROM artists WHERE ArtistID=?', [ArtistID]).fetchone() albums = myDB.select('SELECT * from albums WHERE ArtistID=? order by ReleaseDate DESC', [ArtistID]) + # Don't redirect to the artist page until it has the bare minimum info inserted + # Redirect to the home page if we still can't get it after 5 seconds + retry = 0 + + while retry < 5: + if not artist: + time.sleep(1) + retry += 1 + else: + break + + if not artist: + raise cherrypy.HTTPRedirect("home") + # Serve the extras up as a dict to make things easier for new templates extras_list = ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook"] extras_dict = {} @@ -79,8 +93,6 @@ class WebInterface(object): extras_dict[extra] = "" i+=1 - if artist is None: - raise cherrypy.HTTPRedirect("home") return serve_template(templatename="artist.html", title=artist['ArtistName'], artist=artist, albums=albums, extras=extras_dict) artistPage.exposed = True From 452b83e197f3937690224a99bf8218f86ac23f70 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 20 Aug 2012 16:58:02 +0530 Subject: [PATCH 2/4] Fetch the artist info again during retries when loading artist page --- headphones/webserve.py | 1 + 1 file changed, 1 insertion(+) diff --git a/headphones/webserve.py b/headphones/webserve.py index c1d6674b..14f29a80 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -69,6 +69,7 @@ class WebInterface(object): while retry < 5: if not artist: time.sleep(1) + artist = myDB.action('SELECT * FROM artists WHERE ArtistID=?', [ArtistID]).fetchone() retry += 1 else: break From f9a048b8f8226abccc6d03190d600c89d8a31d27 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 20 Aug 2012 17:06:50 +0530 Subject: [PATCH 3/4] First patch to stop albums with no release date from being marked as wanted - might need some frontend work in the UI to correct the sorting --- headphones/mb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/headphones/mb.py b/headphones/mb.py index 29b5bb8a..36eeeae8 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -326,8 +326,8 @@ def getRelease(releaseid, include_artist_info=True): release['title'] = unicode(results['title']) release['id'] = unicode(results['id']) - release['asin'] = unicode(results['asin']) if 'asin' in results else u'None' - release['date'] = unicode(results['date']) if 'date' in results else u'None' + release['asin'] = unicode(results['asin']) if 'asin' in results else None + release['date'] = unicode(results['date']) if 'date' in results else None try: release['format'] = unicode(results['medium-list'][0]['format']) except: From 6b3e6afd6f27e9c5461aba33721ea3b100591c44 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 20 Aug 2012 17:44:05 +0530 Subject: [PATCH 4/4] Datatables sType=Date on artist page for release dates --- data/interfaces/default/artist.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/interfaces/default/artist.html b/data/interfaces/default/artist.html index 49acbef7..31299d6e 100644 --- a/data/interfaces/default/artist.html +++ b/data/interfaces/default/artist.html @@ -210,7 +210,7 @@ null, null, null, - null, + { "sType": "date" }, null, null, { "sType": "title-numeric"},