Make scoreboard caching only cache the score table (#1586)

* Make scoreboard caching only cache the score table instead of the entire page
* Closes #1584
This commit is contained in:
Kevin Chung
2020-08-13 11:53:36 -04:00
committed by GitHub
parent 58e38c4bde
commit da4357b07b
7 changed files with 46 additions and 7 deletions

View File

@@ -1,6 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask_caching import make_template_fragment_key
from CTFd.cache import clear_standings
from tests.helpers import (
create_ctfd,
@@ -40,13 +42,19 @@ def test_scoreboard_is_cached():
assert app.cache.get("view/api.scoreboard_scoreboard_detail")
# Check scoreboard page
assert app.cache.get("view/scoreboard.listing") is None
assert (
app.cache.get(make_template_fragment_key("public_scoreboard_table"))
is None
)
client.get("/scoreboard")
assert app.cache.get("view/scoreboard.listing")
assert app.cache.get(make_template_fragment_key("public_scoreboard_table"))
# Empty standings and check that the cached data is gone
clear_standings()
assert app.cache.get("view/api.scoreboard_scoreboard_list") is None
assert app.cache.get("view/api.scoreboard_scoreboard_detail") is None
assert app.cache.get("view/scoreboard.listing") is None
assert (
app.cache.get(make_template_fragment_key("public_scoreboard_table"))
is None
)
destroy_ctfd(app)