CTFd / CTFd/CTFd

performance issue caused by solves query on chall listing api

Open
#2,167 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
6.8k
Forks
2.8k
Avg merge
1d 6h
Merged PRs (30d)
5

Description

https://github.com/CTFd/CTFd/blob/e0290cc67b1af531fd19bfeec3e32ade14e248fd/CTFd/api/v1/challenges.py#L193-L212

why is it necessary to return solves count for all challenges? I didn't see CTFd displaying that info anywhere on the listing page.
nevertheless, it should respect filters in `query_args['q']` and `['field']`, or it would walk through *all* challenges on each request, and stuck the database when there is somewhere around 1k challenges (yes...really).

Contributor guide

Open the contributing guide

Research direction

Start in CTFd/api/v1/challenges.py at lines 193-212 and inspect how the solves count is queried during challenge listing. Reproduce the listing request with a large challenge set, then verify that the query respects query_args['q'] and query_args['field'] and no longer walks through all challenges unnecessarily.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, python
Domain
api, backend, databases, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.