Improve caching (#1014)

* Cache get place code for users and teams. 
    * Fix score changing test helpers to clear standings cache when generating a score changing row
    * `utils._get_config` will now return `KeyError` instead of None. 
    * Separate `/api/v1/[users,teams]/[me,id]/[solves,fails,awards]` into seperate API endpoints
* Install `Flask-DebugToolbar` in development

Main goals covered in #1012
This commit is contained in:
Kevin Chung
2019-06-15 02:07:24 -04:00
committed by GitHub
parent e978867a2f
commit e627391b12
14 changed files with 336 additions and 225 deletions

View File

@@ -20,7 +20,7 @@ from CTFd.models import (
Unlocks,
Users,
)
from CTFd.cache import cache
from CTFd.cache import cache, clear_standings
from sqlalchemy_utils import drop_database
from collections import namedtuple
from mock import Mock, patch
@@ -268,6 +268,7 @@ def gen_award(db, user_id, team_id=None, name="award_name", value=100):
award.date = datetime.datetime.utcnow()
db.session.add(award)
db.session.commit()
clear_standings()
return award
@@ -364,6 +365,7 @@ def gen_solve(
solve.date = datetime.datetime.utcnow()
db.session.add(solve)
db.session.commit()
clear_standings()
return solve