Skip to content
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

Merged
merged 8 commits into from
Jun 5, 2024

Conversation

Amaras
Copy link
Collaborator

@Amaras Amaras commented May 30, 2024

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.

@Amaras
Copy link
Collaborator Author

Amaras commented May 31, 2024

This feature is now implemented as I intended and is documented.
It should be able to be merged, awaiting a review.

This use case is probably rare, but at least there's an example of how to do something like this in the future.

@Amaras Amaras mentioned this pull request May 31, 2024
4 tasks
Copy link
Collaborator Author

@Amaras Amaras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before review

Comment on lines +225 to +238
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, )
Copy link
Collaborator Author

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

docs/24-last-results.md Outdated Show resolved Hide resolved
@pascalaubry pascalaubry merged commit f773212 into dev Jun 5, 2024
3 checks passed
@Amaras Amaras deleted the results_screen_multiple_tournaments branch June 5, 2024 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants