Skip to content

Add self-reporting to the Me tab#789

Merged
rlankin merged 10 commits into
Null-Signal-Games:mainfrom
rlankin:self_reporting
May 22, 2026
Merged

Add self-reporting to the Me tab#789
rlankin merged 10 commits into
Null-Signal-Games:mainfrom
rlankin:self_reporting

Conversation

@rlankin
Copy link
Copy Markdown
Contributor

@rlankin rlankin commented May 21, 2026

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.
image

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.

Copy link
Copy Markdown
Contributor

@plural plural left a comment

Choose a reason for hiding this comment

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

I patched this in and it works a treat! Just a couple of small requests for you.

Comment thread app/controllers/rounds_controller.rb Outdated
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how about nil instead of 0?

Comment thread app/controllers/rounds_controller.rb Outdated
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could filter in the query instead of in the code if the user_id is set.

Comment thread app/frontend/pairings/PairingsData.ts Outdated
export async function loadPairings(
tournamentId: number,
): Promise<PairingsData> {
export async function loadPairings(tournamentId: number, userId = 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

null instead of 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add please specify the type for userId

@rlankin rlankin merged commit cfc7efb into Null-Signal-Games:main May 22, 2026
2 checks passed
@rlankin rlankin deleted the self_reporting branch May 22, 2026 16:07
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.

2 participants