@@ -99,6 +99,41 @@ public function singleAction(Request $request, string $id): Response
99
99
return parent ::performSingleAction ($ request , $ id );
100
100
}
101
101
102
+ /**
103
+ * Get the given submission by external ID
104
+ * @throws NonUniqueResultException
105
+ */
106
+ #[IsGranted(new Expression ("is_granted('ROLE_JUDGEHOST') " ))]
107
+ #[Rest \Get('submissions/by-internal-id/{internalId} ' )]
108
+ #[OA \Response(
109
+ response: 200 ,
110
+ description: 'Returns the given submission for this contest by internal ID ' ,
111
+ content: new OA \JsonContent (ref: new Model (type: Submission::class))
112
+ )]
113
+ #[OA \Parameter(ref: '#/components/parameters/id ' )]
114
+ public function singleByExternalIdAction (Request $ request , string $ internalId ): Response
115
+ {
116
+ // Make sure we clear the entity manager class, for when this method is called multiple times
117
+ // by internal requests.
118
+ $ this ->em ->clear ();
119
+
120
+ $ object = $ this ->getQueryBuilder ($ request )
121
+ ->andWhere ('s.submitid = :id ' )
122
+ ->setParameter ('id ' , $ internalId )
123
+ ->getQuery ()
124
+ ->getOneOrNullResult ();
125
+
126
+ if ($ object === null ) {
127
+ throw new NotFoundHttpException (sprintf ('Object with internal ID \'%s \' not found ' , $ internalId ));
128
+ }
129
+
130
+ if ($ this instanceof QueryObjectTransformer) {
131
+ $ object = $ this ->transformObject ($ object );
132
+ }
133
+
134
+ return $ this ->renderData ($ request , $ object );
135
+ }
136
+
102
137
/**
103
138
* Add a submission to this contest.
104
139
* @throws NonUniqueResultException
0 commit comments