Add self-reporting to the Me tab#789
Merged
Merged
Conversation
plural
approved these changes
May 21, 2026
Contributor
plural
left a comment
There was a problem hiding this comment.
I patched this in and it works a treat! Just a couple of small requests for you.
| end | ||
|
|
||
| def pairings_data_round(stage, players, round, self_reports_by_pairing_id) | ||
| def pairings_data_round(stage, players, round, self_reports_by_pairing_id, user_id = 0) |
Contributor
There was a problem hiding this comment.
how about nil instead of 0?
| pairings_reported = 0 | ||
| pairings_fields = %i[id table_number player1_id player2_id side intentional_draw | ||
| two_for_one score1 score1_corp score1_runner score2 score2_corp score2_runner] | ||
| round.pairings.order(:table_number).pluck(pairings_fields).each do | # rubocop:disable Metrics/ParameterLists |
Contributor
There was a problem hiding this comment.
You could filter in the query instead of in the code if the user_id is set.
| export async function loadPairings( | ||
| tournamentId: number, | ||
| ): Promise<PairingsData> { | ||
| export async function loadPairings(tournamentId: number, userId = 0) { |
Contributor
There was a problem hiding this comment.
add please specify the type for userId
plural
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In order to minimize excessive code duplication, I took the opportunity to bring the page more in line with what the rest of the app has been doing since the page was first created. Specifically, this page is basically just a mini, personalized version of the Pairings tab now, since it's showing more or less the same information filtered for only a single player. So, while the overall shape of the page is largely the same, it was reworked to use the same data and components as the Rounds and Pairing components.

The existing pairings_data route was already providing everything we needed and is kind of a bear at the moment, so instead of trying to recreate a narrower version of that I added an optional parameter to it that causes it to return the pairings data for only a specific user. This might be a bit kludgy but it felt like the best option for now, and this code is due for a refactor in the future, anyway.
The tests are extremely simple and copied from the Rounds component tests since we already had self-reporting tests there.