Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Improve global highscore loading speed (wip)

  • Loading branch information...
commit a41d5dd6ba70aaa957190d1b8157cb4fdbebd08b 1 parent 785bed8
@twinther authored
View
3  changelog.txt
@@ -1,7 +1,8 @@
[B]Version 0.5.1 - 2011-12-xx[/B]
- Fixed problem with New game where score, etc. were not reset
- Use script.module.buggalo for error reporting
-- Fix MySQL support for XBMC 11.0
+- Improve MySQL support for XBMC 11.0
+- Improve global highscore loading speed
[B]Version 0.5.0 - 2011-12-07[/B]
- Improvied support for XBMC Eden
View
2  quizlib/db.py
@@ -698,7 +698,7 @@ def _find_newest_database(self, settings):
db = 'information_schema'
)
c = conn.cursor()
- c.execute('SELECT schema_name FROM schemata WHERE schema_name LIKE "MyVideos%"')
+ c.execute('SELECT schema_name FROM schemata WHERE schema_name LIKE "%s%%"' % settings['name'])
rows = c.fetchall()
c.close()
conn.close()
View
12 quizlib/gui.py
@@ -117,26 +117,26 @@ def onInit(self):
del loadingGui
# Check preconditions
- if not self.database.hasMovies() and not self.database.hasTVShows():
+ if False:#not self.database.hasMovies() and not self.database.hasTVShows():
# Must have at least one movie or tvshow
xbmcgui.Dialog().ok(strings(E_REQUIREMENTS_MISSING), strings(E_REQUIREMENTS_MISSING_LINE1),
strings(E_REQUIREMENTS_MISSING_LINE2), strings(E_REQUIREMENTS_MISSING_LINE3))
self.close()
return
- if not self.database.isAnyVideosWatched() and ADDON.getSetting(SETT_ONLY_WATCHED_MOVIES) == 'true':
+ if False:#not self.database.isAnyVideosWatched() and ADDON.getSetting(SETT_ONLY_WATCHED_MOVIES) == 'true':
# Only watched movies requires at least one watched video files
xbmcgui.Dialog().ok(strings(E_REQUIREMENTS_MISSING), strings(E_ONLY_WATCHED_LINE1),
strings(E_ONLY_WATCHED_LINE2), strings(E_ONLY_WATCHED_LINE3))
ADDON.setSetting(SETT_ONLY_WATCHED_MOVIES, 'false')
- if not self.database.isAnyMPAARatingsAvailable() and ADDON.getSetting(SETT_MOVIE_RATING_LIMIT_ENABLED) == 'true':
+ if False:#not self.database.isAnyMPAARatingsAvailable() and ADDON.getSetting(SETT_MOVIE_RATING_LIMIT_ENABLED) == 'true':
# MPAA rating requires ratings to be available in database
xbmcgui.Dialog().ok(strings(E_REQUIREMENTS_MISSING), strings(E_MOVIE_RATING_LIMIT_LINE1),
strings(E_MOVIE_RATING_LIMIT_LINE2), strings(E_MOVIE_RATING_LIMIT_LINE3))
ADDON.setSetting(SETT_MOVIE_RATING_LIMIT_ENABLED, 'false')
- if not self.database.isAnyContentRatingsAvailable() and ADDON.getSetting(SETT_TVSHOW_RATING_LIMIT_ENABLED) == 'true':
+ if False:#not self.database.isAnyContentRatingsAvailable() and ADDON.getSetting(SETT_TVSHOW_RATING_LIMIT_ENABLED) == 'true':
# Content rating requires ratings to be available in database
xbmcgui.Dialog().ok(strings(E_REQUIREMENTS_MISSING), strings(E_TVSHOW_RATING_LIMIT_LINE1),
strings(E_TVSHOW_RATING_LIMIT_LINE2), strings(E_TVSHOW_RATING_LIMIT_LINE3))
@@ -986,7 +986,7 @@ def _setupHighscores(self):
newHighscoreId = localHighscore.addHighscore(self.game)
name = localHighscore.getNickname(self.game.getUserId())
- entries = localHighscore.getHighscores(self.game)
+ entries = localHighscore.getHighscoresNear(self.game, newHighscoreId)
localHighscore.close()
subTypeText = None
@@ -1026,7 +1026,7 @@ def _setupHighscores(self):
else:
newHighscoreId = -1
- entries = globalHighscore.getHighscores(self.game)
+ entries = globalHighscore.getHighscoresNear(self.game, newHighscoreId)
self.getControl(self.C_GAMEOVER_GLOBAL_HIGHSCORE_TYPE).setLabel(subTypeText)
items = list()
selectedIndex = -1
View
37 quizlib/highscore.py
@@ -22,6 +22,8 @@
import urllib2
import hashlib
import os
+import StringIO
+import gzip
import xbmc
@@ -36,7 +38,7 @@ def getHighscores(self, game):
"""
raise
- def getHighscoresNear(self, game, highscoreId):
+ def getHighscoresNear(self, game, highscoreId, limit = 50):
"""
@type game: quizlib.game.Game
@param game: game instance
@@ -93,8 +95,21 @@ def getHighscores(self, game):
else:
return []
- def getHighscoresNear(self, game, highscoreId):
- return self.getHighscores(game)
+ def getHighscoresNear(self, game, highscoreId, limit = 50):
+ req = {
+ 'action' : 'highscores-near',
+ 'type' : game.getType(),
+ 'gameType' : game.getGameType(),
+ 'gameSubType' : game.getGameSubType(),
+ 'highscoreId' : highscoreId,
+ 'limit' : limit
+ }
+
+ resp = self._request(req)
+ if resp['status'] == 'OK':
+ return resp['highscores']
+ else:
+ return []
def getStatistics(self):
req = {
@@ -114,11 +129,21 @@ def _request(self, data):
req = urllib2.Request(self.SERVICE_URL, jsonData)
req.add_header('X-MovieQuiz-Checksum', checksum)
req.add_header('Content-Type', 'text/json')
+ req.add_header('Accept-encoding', 'gzip')
+
+ print jsonData
+ print req.headers
try:
u = urllib2.urlopen(req)
- resp = u.read()
+ if u.info().get('Content-Encoding') == 'gzip':
+ buf = StringIO.StringIO(u.read())
+ f = gzip.GzipFile(fileobj=buf)
+ resp = f.read()
+ else:
+ resp = u.read()
u.close()
+
return simplejson.loads(resp)
except urllib2.URLError:
return {'status' : 'error'}
@@ -166,14 +191,14 @@ def getHighscores(self, game):
[game.getType(), game.getGameType(), game.getGameSubType()])
return c.fetchall()
- def getHighscoresNear(self, game, highscoreId):
+ def getHighscoresNear(self, game, highscoreId, limit = 50):
c = self.conn.cursor()
c.execute('SELECT position FROM highscore WHERE id=?', [highscoreId])
r = c.fetchone()
position = r['position']
c.execute("SELECT h.*, u.nickname FROM highscore h, user u WHERE h.user_id=u.id AND h.type=? AND h.gameType=? and h.gameSubType=? AND h.position > ? AND h.position < ? ORDER BY h.position",
- [game.getType(), game.getGameType(), game.getGameSubType(), position - 5, position + 5])
+ [game.getType(), game.getGameType(), game.getGameSubType(), position - (limit / 2), position + (limit / 2)])
return c.fetchall()
def createUser(self, nickname):
View
26 resources/skins/Default/720p/script-moviequiz-about.xml
@@ -230,6 +230,32 @@
<align>right</align>
</control>
+ <control type="group">
+ <posx>300</posx>
+ <posy>250</posy>
+ <width>470</width>
+ <height>55</height>
+ <visible>!IntegerGreaterThan(Container(1001).NumItems,0)</visible>
+ <animation effect="fade" start="0" end="100" time="300">VisibleChange</animation>
+
+ <control type="image">
+ <posx>0</posx>
+ <posy>0</posy>
+ <width>54</width>
+ <height>55</height>
+ <texture>loading.gif</texture>
+ </control>
+ <control type="label">
+ <posx>70</posx>
+ <posy>0</posy>
+ <width>400</width>
+ <height>55</height>
+ <label>$ADDON[script.moviequiz 30008]</label>
+ <aligny>center</aligny>
+ <font>font30</font>
+ </control>
+ </control>
+
<control type="list" id="1001">
<posx>0</posx>
<posy>90</posy>
View
BIN  resources/skins/Default/media/loading.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.