Skip to content

Add endpoint to fetch submissions by internal ID for domlogo #3002

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions webapp/src/Controller/API/SubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,41 @@ public function singleAction(Request $request, string $id): Response
return parent::performSingleAction($request, $id);
}

/**
* Get the given submission by external ID
* @throws NonUniqueResultException
*/
#[IsGranted(new Expression("is_granted('ROLE_JUDGEHOST')"))]
#[Rest\Get('submissions/by-internal-id/{internalId}')]
#[OA\Response(
response: 200,
description: 'Returns the given submission for this contest by internal ID',
content: new OA\JsonContent(ref: new Model(type: Submission::class))
)]
#[OA\Parameter(ref: '#/components/parameters/id')]
public function singleByExternalIdAction(Request $request, string $internalId): Response
{
// Make sure we clear the entity manager class, for when this method is called multiple times
// by internal requests.
$this->em->clear();

$object = $this->getQueryBuilder($request)
->andWhere('s.submitid = :id')
->setParameter('id', $internalId)
->getQuery()
->getOneOrNullResult();

if ($object === null) {
throw new NotFoundHttpException(sprintf('Object with internal ID \'%s\' not found', $internalId));
}

if ($this instanceof QueryObjectTransformer) {
$object = $this->transformObject($object);
}

return $this->renderData($request, $object);
}

/**
* Add a submission to this contest.
* @throws NonUniqueResultException
Expand Down
Loading