Skip to content

Commit

Permalink
refactor objects structure for #52
Browse files Browse the repository at this point in the history
  • Loading branch information
nzinov committed May 17, 2014
1 parent 14dee51 commit 1ae52d5
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 50 deletions.
2 changes: 1 addition & 1 deletion handlers/global_dictionary/complain_word.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from google.appengine.ext import ndb

from handlers import AdminRequestHandler, AuthorizedAPIRequestHandler
from objects.global_dictionary_word import GlobalDictionaryWord
from objects.global_dictionary import GlobalDictionaryWord
from objects.complained_word import ComplainedWord
from objects.user_devices import get_device_and_user

Expand Down
4 changes: 2 additions & 2 deletions handlers/global_dictionary/editor.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#TODO: this file is obsolete and must be rewritten
from objects.global_dictionary import GlobalDictionaryJson
from handlers import AdminRequestHandler

__author__ = 'ivan'

import json

from environment import JINJA_ENVIRONMENT
from objects.global_dictionary_word import GlobalDictionaryWord
from objects.GlobalDictionaryJSON import GlobalDictionaryJson
from objects.global_dictionary import GlobalDictionaryWord


class GlobalDictionaryWordList(AdminRequestHandler):
Expand Down
2 changes: 1 addition & 1 deletion handlers/global_dictionary/unknown_words.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from google.appengine.ext import ndb
from handlers import AdminRequestHandler
from objects.global_dictionary_word import GlobalDictionaryWord
from objects.global_dictionary import GlobalDictionaryWord

__author__ = 'ivan'

Expand Down
2 changes: 1 addition & 1 deletion handlers/global_dictionary/word_lookup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from handlers import AdminRequestHandler

__author__ = 'nikolay'
from objects.global_dictionary_word import WordLookup
from objects.global_dictionary import WordLookup
import json


Expand Down
4 changes: 2 additions & 2 deletions handlers/global_dictionary/words.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from objects.global_dictionary import GlobalDictionaryJson
from handlers import AdminRequestHandler, APIRequestHandler, ServiceRequestHandler

__author__ = 'ivan'
Expand All @@ -8,8 +9,7 @@
from google.appengine.api import taskqueue
from google.appengine.ext import ndb

from objects.global_dictionary_word import GlobalDictionaryWord
from objects.GlobalDictionaryJSON import GlobalDictionaryJson
from objects.global_dictionary import GlobalDictionaryWord


StrategyTypeChooseConstant = 200
Expand Down
2 changes: 1 addition & 1 deletion handlers/statistics/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from google.appengine.api import taskqueue
from google.appengine.api import memcache

from objects.global_dictionary_word import GlobalDictionaryWord
from objects.global_dictionary import GlobalDictionaryWord
from environment import TRUESKILL_ENVIRONMENT
from objects.game_results_log import GameLog
from objects.legacy_game_history import GameHistory
Expand Down
2 changes: 1 addition & 1 deletion handlers/statistics/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = 'ivan'

from objects.global_dictionary_word import GlobalDictionaryWord
from objects.global_dictionary import GlobalDictionaryWord

from google.appengine.api import taskqueue
from google.appengine.ext import ndb
Expand Down
2 changes: 1 addition & 1 deletion handlers/statistics/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from google.appengine.ext import ndb
from google.appengine.api import taskqueue

from objects.global_dictionary_word import GlobalDictionaryWord
from objects.global_dictionary import GlobalDictionaryWord


class Plot(ndb.Model):
Expand Down
2 changes: 1 addition & 1 deletion handlers/statistics/total.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from handlers.statistics.plots import Plot
from objects.total_statistics_object import *
from objects.global_dictionary_word import GlobalDictionaryWord
from objects.global_dictionary import GlobalDictionaryWord


class ScattedPlotHandler(APIRequestHandler):
Expand Down
2 changes: 1 addition & 1 deletion handlers/statistics/word.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = 'ivan'

from objects.global_dictionary_word import GlobalDictionaryWord
from objects.global_dictionary import GlobalDictionaryWord
from google.appengine.api import memcache
from random import randint

Expand Down
8 changes: 0 additions & 8 deletions objects/GlobalDictionaryJSON.py

This file was deleted.

29 changes: 27 additions & 2 deletions objects/global_dictionary_word.py → objects/global_dictionary.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import constants

__author__ = 'ivan'

from google.appengine.ext import ndb
from google.appengine.ext import ndb, db
from google.appengine.api import memcache


Expand Down Expand Up @@ -35,4 +37,27 @@ def get(word):
return None
proper_word = proper_word.proper_word
memcache.set(u"word_lookup_{}".format(word), proper_word, time=60*60*12)
return ndb.Key(GlobalDictionaryWord, proper_word).get()
return ndb.Key(GlobalDictionaryWord, proper_word).get()


class GlobalDictionaryVersion(db.Model):
version = db.IntegerProperty()

@staticmethod
def get_server_version():
version = GlobalDictionaryVersion.get_by_key_name(constants.version_key)
return 0 if version is None else int(version.version)

@staticmethod
def update_version():
version = GlobalDictionaryVersion.get_by_key_name(constants.version_key)
if version is None:
version = GlobalDictionaryVersion(key_name=constants.version_key, version=1)
else:
version.version += 1
version.put()


class GlobalDictionaryJson(ndb.Model):
json = ndb.TextProperty()
timestamp = ndb.IntegerProperty(indexed=True)
22 changes: 0 additions & 22 deletions objects/global_dictionary_version.py

This file was deleted.

3 changes: 1 addition & 2 deletions tests/complain_word_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
__author__ = 'ivan'
import json

import webapp2
from google.appengine.ext import testbed
import unittest2

from objects.complained_word import ComplainedWord
from objects.global_dictionary_word import GlobalDictionaryWord
from objects.global_dictionary import GlobalDictionaryWord
from google.appengine.ext import ndb
from tests.base_functions import *
import main
Expand Down
2 changes: 1 addition & 1 deletion tests/frequency_dictionary_handler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import unittest2
from google.appengine.ext import testbed

from global_dictionary.frequency import WordFrequency
from handlers.global_dictionary.frequency import WordFrequency
from tests.base_functions import *
import main

Expand Down
5 changes: 3 additions & 2 deletions tests/global_dictionary_word_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from objects.global_dictionary import GlobalDictionaryJson

__author__ = 'ivan'

import unittest2
Expand All @@ -8,8 +10,7 @@

from google.appengine.ext import testbed

from objects.global_dictionary_word import GlobalDictionaryWord
from objects.GlobalDictionaryJSON import GlobalDictionaryJson
from objects.global_dictionary import GlobalDictionaryWord
from tests.base_functions import *
import main

Expand Down
2 changes: 1 addition & 1 deletion tests/recalc_rating_handler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import webapp2
from google.appengine.ext import testbed, ndb

from objects.global_dictionary_word import GlobalDictionaryWord
from objects.global_dictionary import GlobalDictionaryWord
from objects.game_results_log import GameLog
from objects.legacy_game_history import GameHistory, WordGuessResult, Word, Round
import main
Expand Down

0 comments on commit 1ae52d5

Please sign in to comment.