mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 14:04:20 +01:00
Cache challenge data for faster loading of /api/v1/challenges (#2232)
* Improve response time of `/api/v1/challenges` and `/api/v1/challenges/[challenge_id]/solves` * Rewrite and remove _build_solves_query to make it cacheable * Closes #2209
This commit is contained in:
@@ -15,7 +15,7 @@ from sqlalchemy_utils import drop_database
|
||||
from werkzeug.datastructures import Headers
|
||||
|
||||
from CTFd import create_app
|
||||
from CTFd.cache import cache, clear_standings
|
||||
from CTFd.cache import cache, clear_challenges, clear_standings
|
||||
from CTFd.config import TestingConfig
|
||||
from CTFd.models import (
|
||||
Awards,
|
||||
@@ -336,6 +336,7 @@ def gen_challenge(
|
||||
)
|
||||
db.session.add(chal)
|
||||
db.session.commit()
|
||||
clear_challenges()
|
||||
return chal
|
||||
|
||||
|
||||
@@ -455,6 +456,7 @@ def gen_solve(
|
||||
db.session.add(solve)
|
||||
db.session.commit()
|
||||
clear_standings()
|
||||
clear_challenges()
|
||||
return solve
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user