Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
nzinov committed Mar 28, 2014
1 parent c56828b commit a863d20
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
12 changes: 4 additions & 8 deletions handlers/recalc_rating_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def post(self):
words_db = []
for word_db in words:
if word_db is None:
logging.warning(u"There is no word '{}' in our dictionary".format(word))
continue
words_db.append(word_db)
ratings.append((TRUESKILL_ENVIRONMENT.create_rating(mu=word_db.E, sigma=word_db.D), ))
Expand Down Expand Up @@ -290,18 +289,15 @@ def post(self):
RecalcAllLogs.delete_all_stat()
f2 = GlobalDictionaryWord.query(GlobalDictionaryWord.used_times > 0).map_async(self.reset_word)
f2.get_result()
q1 = taskqueue.Queue('statistic-calculation')
q2 = taskqueue.Queue('logs-processing')
f1 = GameLog.query().map_async(lambda k: q1.add_async(taskqueue.Task(url='/internal/calculate_total_statistics',
params={'game_id': k.id()})), keys_only=True)
f2 = GameLog.query().map_async(lambda k: q2.add_async(taskqueue.Task(url='/internal/add_game_to_statistic',
params={'game_id': k.id()})), keys_only=True)
f3 = GameHistory.query(GameHistory.ignored == False).map_async(
f1 = GameLog.query().map_async(lambda k: q2.add_async(taskqueue.Task(url='/internal/add_game_to_statistic',
params={'game_id': k.id()})),
keys_only=True)
f2 = GameHistory.query(GameHistory.ignored == False).map_async(
lambda k: q2.add_async(taskqueue.Task(url='/internal/add_legacy_game',
params={'game_id': k.id()})), keys_only=True)
f1.get_result()
f2.get_result()
f3.get_result()


class LogsAdminPage(AdminRequestHandler):
Expand Down
3 changes: 2 additions & 1 deletion handlers/statistics/word_statistics_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def get(self, *args, **kwargs):
if not c:
c = q.count()
memcache.set("used_words_count", c)
rand = q.fetch(limit=10, offset=randint(0, c-10))
if c >= 10:
rand = q.fetch(limit=10, offset=randint(0, c-10))
self.draw_page('statistics/word_statistic', word=word, word_entity=entity, games=games,
top=top, bottom=bottom, rand=rand)

4 changes: 1 addition & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# limitations under the License.
#
import webapp2
from google.appengine.api import users

import handlers
import handlers.dictionaries_packages_handlers
Expand All @@ -33,7 +32,6 @@
import handlers.legacy_game_history_handler
import handlers.remove_duplicates

from environment import JINJA_ENVIRONMENT
import handlers.admin_page_handler
import handlers.pregame_handlers
import handlers.statistics.total_statistics_handler
Expand Down Expand Up @@ -65,7 +63,7 @@ def get(self):
handler=handlers.recalc_rating_handler.AddGameHandler,
name='add_game_Statistic'),
webapp2.Route(r'/internal/recalc_all_logs',
handler=handlers.recalc_rating_handler.RecalcAllLogs),
handler=handlers.recalc_rating_handler.RecalcAllLogs),
webapp2.Route(r'/internal/add_legacy_game',
handler=handlers.legacy_game_history_handler.LegacyStatisticsHandler,
name='add_game_Statistic'),
Expand Down
6 changes: 3 additions & 3 deletions templates/statistics/word_statistic.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{% for word in list %}
<tr>
<td>{{ loop.index }}</td>
<td><a href="/word_statistics?word={{ word.word }}">{{ word.word }}</a></td>
<td><a href="statistics/word_statistics?word={{ word.word }}">{{ word.word }}</a></td>
<td>{{ word.E|round(1) }}</td>
</tr>
{% endfor %}
Expand All @@ -31,7 +31,7 @@
<div class="alert alert-danger">К сожалению, в нашем словаре нет слова "{{ word }}"</div>
{% endif %}
<h2>Выберите, статистику по какому слову вы хотите посмотреть:</h2>
<form style="margin-left: 30px" class="form-inline" method="get" action="/word_statistics">
<form style="margin-left: 30px" class="form-inline" method="get" action="statistics/word_statistics">
<div class="form-group">
<input type="search" class="form-control" name="word" placeholder="Слово">
</div>
Expand All @@ -58,7 +58,7 @@ <h2>Выберите, статистику по какому слову вы х
<div class="row">
<div class="col-md-6"><p class="lead">Показана статистика по слову "{{ word_entity.word }}"</p></div>
<div class="col-md-6">
<form class="form-inline" method="get" action="/word_statistics">
<form class="form-inline" method="get" action="statistics/word_statistics">
<div class="form-group">
<input type="search" class="form-control" name="word" placeholder="Слово">
</div>
Expand Down

0 comments on commit a863d20

Please sign in to comment.