(domainId: string, psid: ObjectId, uid: number, value: number)
| 70 | } |
| 71 | |
| 72 | static async vote(domainId: string, psid: ObjectId, uid: number, value: number) { |
| 73 | const doc = await document.get(domainId, document.TYPE_PROBLEM_SOLUTION, psid); |
| 74 | if (!doc) throw new SolutionNotFoundError(domainId, psid); |
| 75 | const before = await document.setStatus( |
| 76 | domainId, document.TYPE_PROBLEM_SOLUTION, psid, uid, |
| 77 | { vote: value }, null, 'before', |
| 78 | ); |
| 79 | let inc = value; |
| 80 | if (before?.vote) inc -= before.vote; |
| 81 | return inc |
| 82 | ? await document.inc(domainId, document.TYPE_PROBLEM_SOLUTION, psid, 'vote', inc) |
| 83 | : doc; |
| 84 | } |
| 85 | |
| 86 | static async getListStatus(domainId: string, psids: ObjectId[], uid: number) { |
| 87 | const result: Record<string, { docId: ObjectId, vote: number }> = {}; |
no test coverage detected