mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 14:34:21 +01:00
Add a bell curve graph and total points calculation (#1325)
* Add a bell curve graph and total points calculation to admin panel statistics * Closes #608
This commit is contained in:
0
tests/api/v1/statistics/__init__.py
Normal file
0
tests/api/v1/statistics/__init__.py
Normal file
32
tests/api/v1/statistics/test_scores.py
Normal file
32
tests/api/v1/statistics/test_scores.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from CTFd.models import Users
|
||||
from tests.helpers import (
|
||||
create_ctfd,
|
||||
destroy_ctfd,
|
||||
login_as_user,
|
||||
register_user,
|
||||
simulate_user_activity,
|
||||
)
|
||||
|
||||
|
||||
def test_api_statistics_score_distribution():
|
||||
app = create_ctfd()
|
||||
with app.app_context():
|
||||
# Handle zero data case
|
||||
client = login_as_user(app, name="admin", password="password")
|
||||
r = client.get("/api/v1/statistics/scores/distribution")
|
||||
resp = r.get_json()
|
||||
assert resp["data"]["brackets"] == {}
|
||||
|
||||
# Add user data
|
||||
register_user(app)
|
||||
user = Users.query.filter_by(email="user@ctfd.io").first()
|
||||
simulate_user_activity(app.db, user=user)
|
||||
|
||||
# Test again
|
||||
r = client.get("/api/v1/statistics/scores/distribution")
|
||||
resp = r.get_json()
|
||||
assert resp["data"]["brackets"]
|
||||
destroy_ctfd(app)
|
||||
@@ -15,6 +15,7 @@ def test_api_hint_404():
|
||||
"/api/v1/statistics/users/{}",
|
||||
"/api/v1/configs",
|
||||
"/api/v1/statistics/challenges/solves/percentages",
|
||||
"/api/v1/statistics/scores/distribution",
|
||||
"/api/v1/tags/{}",
|
||||
"/api/v1/pages",
|
||||
"/api/v1/files/{}",
|
||||
|
||||
Reference in New Issue
Block a user