diff --git a/dawgdictionary.py b/dawgdictionary.py index 4728f76a..ce5e8df3 100644 --- a/dawgdictionary.py +++ b/dawgdictionary.py @@ -58,8 +58,6 @@ import time import cPickle as pickle -from functools32 import lru_cache - from languages import Alphabet @@ -161,9 +159,6 @@ def num_nodes(self): """ Return a count of unique nodes in the DAWG """ return 0 if self._nodes is None else len(self._nodes) - # This is a very common code path. - # Use LRU caching from functools32 to speed up lookups of common words - @lru_cache(maxsize = 1024) def find(self, word): """ Look for a word in the graph, returning True if it is found or False if not """ nav = FindNavigator(word) diff --git a/netskrafl.py b/netskrafl.py index 0742b2a3..0741b18a 100644 --- a/netskrafl.py +++ b/netskrafl.py @@ -53,7 +53,7 @@ app = Flask(__name__) -running_local = os.environ.get('SERVER_SOFTWARE','').startswith('Development') +running_local = os.environ.get('SERVER_SOFTWARE', '').startswith('Development') if running_local: logging.info(u"Netskrafl app running with DEBUG set to True") @@ -1190,6 +1190,9 @@ def store(self, usr): uf = UserForm() err = dict() + # The URL to go back to, if not main.html + from_url = request.args.get("from", None) + if request.method == 'GET': # Entering the form for the first time: load the user data uf.init_from_user(user) @@ -1200,10 +1203,10 @@ def store(self, usr): if not err: # All is fine: store the data back in the user entity uf.store(user) - return redirect(url_for("main")) + return redirect(from_url or url_for("main")) # Render the form with the current data and error messages, if any - return render_template("userprefs.html", uf = uf, err = err) + return render_template("userprefs.html", uf = uf, err = err, from_url = from_url) @app.route("/wait") diff --git a/skrafldb.py b/skrafldb.py index 2c78e863..38f7c81f 100644 --- a/skrafldb.py +++ b/skrafldb.py @@ -332,20 +332,23 @@ def game_callback(gm): human_elo_adj = human_elo_adj, prefs = gm.prefs) - k = ndb.Key(UserModel, user_id) # Run the query in two parts as experience suggests that # AppEngine is not efficient with ndb.OR between two distinct values # This also means that the returned list may be twice max_len + k = ndb.Key(UserModel, user_id) + q = cls.query(GameModel.over == True) \ - .filter(GameModel.player0 == k) + .filter(GameModel.player0 == k) \ + .order(-GameModel.ts_last_move) for gm in q.fetch(max_len): yield game_callback(gm) q = cls.query(GameModel.over == True) \ - .filter(GameModel.player1 == k) + .filter(GameModel.player1 == k) \ + .order(-GameModel.ts_last_move) for gm in q.fetch(max_len): yield game_callback(gm) diff --git a/templates/board.html b/templates/board.html index c4cfc152..afa07aa0 100644 --- a/templates/board.html +++ b/templates/board.html @@ -561,7 +561,7 @@
function navToUserprefs() { /* Show the user preferences page */ - window.location.href = "{{ url_for('userprefs') | safe }}"; + window.location.href = "{{ url_for('userprefs', from = url_for('board', game = game.id())) | safe }}"; } function fbShare() { diff --git a/templates/login.html b/templates/login.html index d346bd9f..7b1dd1a5 100644 --- a/templates/login.html +++ b/templates/login.html @@ -19,7 +19,7 @@ Skemmtilegt | skerpandi | ókeypis