mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 06:24:23 +01:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user