File tree Expand file tree Collapse file tree 1 file changed +21
-13
lines changed Expand file tree Collapse file tree 1 file changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -178,20 +178,28 @@ FROM [PolygonJudgings] AS [p]
178
178
}
179
179
else if ( context . Database . ProviderName == "Npgsql.EntityFrameworkCore.PostgreSQL" )
180
180
{
181
- /*
182
- UPDATE server_info
183
- SET status = 'active'
184
- WHERE server_ip = (
185
- SELECT server_ip
186
- FROM server_info
187
- WHERE status = 'standby'
188
- LIMIT 1
189
- FOR UPDATE SKIP LOCKED
190
- )
191
- RETURNING server_ip;
192
- */
181
+ DateTimeOffset now = DateTimeOffset . Now ;
182
+ FormattableString sql =
183
+ $@ "UPDATE ""PolygonJudgings"" AS p
184
+ SET ""Server"" = { judgehostName } , ""StartTime"" = { now } , ""Status"" = { ( int ) Verdict . Running }
185
+ WHERE p.""JudgingId"" = (
186
+ SELECT p.""JudgingId""
187
+ FROM ""PolygonJudgings"" AS p
188
+ INNER JOIN ""PolygonSubmissions"" AS p0 ON p.""SubmissionId"" = p0.""SubmissionId""
189
+ INNER JOIN ""PolygonLanguages"" AS p1 ON p0.""Language"" = p1.""LangId""
190
+ INNER JOIN ""PolygonProblems"" AS p2 ON p0.""ProblemId"" = p2.""ProblemId""
191
+ WHERE (((p.""Status"" = 8) AND p1.""AllowJudge"") AND p2.""AllowJudge"") AND NOT (p0.""Ignored"")
192
+ ORDER BY p.""JudgingId""
193
+ LIMIT 1
194
+ FOR UPDATE SKIP LOCKED
195
+ )
196
+ RETURNING ""JudgingId""" ;
193
197
194
- throw new NotImplementedException ( ) ;
198
+ var results = await context . Set < SingleEntry > ( )
199
+ . FromSqlInterpolated ( sql )
200
+ . ToListAsync ( ) ;
201
+
202
+ return results . SingleOrDefault ( ) ? . Id ;
195
203
}
196
204
else
197
205
{
You can’t perform that action at this time.
0 commit comments