()
| 60 | } |
| 61 | |
| 62 | export async function getAllProblems() { |
| 63 | const value = await cache.get("getAllProblems", []); |
| 64 | if (value) { |
| 65 | return value; |
| 66 | } |
| 67 | try { |
| 68 | const problems = await db.problem.findMany({ |
| 69 | orderBy: { |
| 70 | id: "desc", |
| 71 | }, |
| 72 | }); |
| 73 | await cache.set("getAllProblems", [], problems); |
| 74 | return problems; |
| 75 | } catch (e) { |
| 76 | return []; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | export async function updateProblem(problemId: string, data: Problem) { |
| 81 | try { |