Full refactor to Typescript

This commit is contained in:
2022-11-17 19:19:33 +01:00
parent de3f10b3ee
commit ffd3c99292
19 changed files with 180 additions and 95 deletions
+5 -3
View File
@@ -3,7 +3,7 @@ import crypto from 'crypto'
import { readFile, writeFile, access, constants } from 'fs/promises'
import {
CommonProps as MetaProps,
MetadataProps as MetaProps,
Problem,
ProblemId,
Solution,
@@ -191,14 +191,16 @@ export const updateSolution = (
})
type SolutionsQuery = Partial<{
sentBy: UserId
forProblem: ProblemId
sentBy?: UserId
forProblem?: ProblemId
}>
export const getSolutions = (db: DatabaseConnection, { sentBy, forProblem }: SolutionsQuery = {}) =>
withDatabase(db, state => {
let solutions = Object.values(state.solutions)
console.log(solutions.length, sentBy, forProblem)
if (sentBy) {
solutions = solutions.filter(s => s.sentBy === sentBy)
}