Add GET /submissions/user-answer/{userAnswerId}#38
Conversation
|
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. |
|
|
||
| export async function findSubmissionByUserAnswerId(userAnswerId: string): Promise<Submission|null> { | ||
| return await Db.querySingleResult<Submission>('SELECT * FROM tm_submissions WHERE idUserAnswer = ?', [userAnswerId]); | ||
| } |
There was a problem hiding this comment.
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.
| export async function findSubmissionByUserAnswerId(userAnswerId: string): Promise<Submission|null> { | ||
| return await Db.querySingleResult<Submission>('SELECT * FROM tm_submissions WHERE idUserAnswer = ?', [userAnswerId]); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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 |
No description provided.