Skip to content

Add GET /submissions/user-answer/{userAnswerId}#38

Merged
SebastienTainon merged 2 commits into
masterfrom
add-get-submission-by-user-answer
Jun 12, 2026
Merged

Add GET /submissions/user-answer/{userAnswerId}#38
SebastienTainon merged 2 commits into
masterfrom
add-get-submission-by-user-answer

Conversation

@SebastienTainon

Copy link
Copy Markdown
Contributor

No description provided.

@SebastienTainon SebastienTainon requested a review from smadbe May 29, 2026 09:09
@smadbe

smadbe commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

A description would be useful when you submit a PR for review. It is good to know the objective of a work before reviewing it.

Comment thread src/submissions.ts

export async function findSubmissionByUserAnswerId(userAnswerId: string): Promise<Submission|null> {
return await Db.querySingleResult<Submission>('SELECT * FROM tm_submissions WHERE idUserAnswer = ?', [userAnswerId]);
}

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.

The db schema indicates idUserAnswer is not unique, so technically you may still have cases (even related when manual tests) where you have twice the same "idUserAnswer" in the table. If so, the fact that you have no ordering, make this function not really deterministic. An "order by" would at least make sure the output of this function is more predictable.

Comment thread src/submissions.ts Outdated
Comment on lines +287 to +288
export async function findSubmissionByUserAnswerId(userAnswerId: string): Promise<Submission|null> {
return await Db.querySingleResult<Submission>('SELECT * FROM tm_submissions WHERE idUserAnswer = ?', [userAnswerId]);

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.

If the schema.sql is up to date (I don't know as they are no migrations files 🤔), idUserAnswer is not an index, so this function will do a full table scan, which will become very slow quite quikcly.

@SebastienTainon SebastienTainon Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes I don't know either actually how Michel is deploying, I'll ask him. But it's a bit awkward because two different projects currently share the same database (TaskPlatform and this one), and one has migration files. Perhaps I should add all my migrations in the other project.

@SebastienTainon

Copy link
Copy Markdown
Contributor Author

A description would be useful when you submit a PR for review. It is good to know the objective of a work before reviewing it.

Sorry I had explained the objective in Slack and you had answered so I thought it was sufficient but next time I'll copy it over to Github too

@SebastienTainon SebastienTainon merged commit 0193894 into master Jun 12, 2026
2 checks passed
@SebastienTainon SebastienTainon deleted the add-get-submission-by-user-answer branch June 12, 2026 08:04
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