-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow restriction of tournaments on results screens #35
Conversation
This feature is now implemented as I intended and is documented. This use case is probably rare, but at least there's an example of how to do something like this in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before review
query_parts: list[str] = [] | ||
params: tuple = () | ||
for tournament in tournaments: | ||
query_part: str = ('SELECT `tournament_id`, `round`, `board_id`, `white_player`, `black_player`, `date`, `value` ' | ||
'FROM `result` WHERE `tournament_id` = ? ORDER BY `date` DESC') | ||
params += (tournament, ) | ||
if limit: | ||
query_part += ' LIMIT ?' | ||
params += (limit, ) | ||
query_parts.append('\n'.join(('SELECT * FROM (', query_part, ')'))) | ||
query: str = '\nUNION\n'.join(query_parts) + ' ORDER BY `date` DESC' | ||
if limit: | ||
query += ' LIMIT ?' | ||
params += (limit, ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if IN (?, ?, ...)
pattern is possible in SQLITE prepared statements
…-web-org/papi-web into results_screen_multiple_tournaments
Improvement of results screens mentioned in #27: only include specified tournaments in a screen of type
results
.This is untested for now (coded on Linux), as the query can be quite problematic.
Documentation was not modified to reflect the change yet.