(problemId: string | null)
| 17 | } |
| 18 | |
| 19 | export async function getProblem(problemId: string | null) { |
| 20 | if (!problemId) { |
| 21 | return null; |
| 22 | } |
| 23 | const value: Problem = await cache.get("problems", [problemId.toString()]); |
| 24 | if (value) { |
| 25 | return value; |
| 26 | } |
| 27 | try { |
| 28 | const problem = await db.problem.findUnique({ |
| 29 | where: { |
| 30 | id: problemId, |
| 31 | }, |
| 32 | }); |
| 33 | await cache.set("problems", [problemId.toString()], problem); |
| 34 | return problem; |
| 35 | } catch (err) { |
| 36 | return null; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | export async function getFirstProblemForTrack(trackId: string) { |
| 41 | const value = await cache.get("tracks", [trackId.toString()]); |
no test coverage detected