Revamped the statistical page to work with the new entity system, along with some other improvements to it
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Session} from "@/hooks/useSessions";
|
||||
import { Session } from "@/hooks/useSessions";
|
||||
import client from "@/lib/mongodb";
|
||||
|
||||
const db = client.db(process.env.MONGODB_DB);
|
||||
@@ -6,11 +6,16 @@ const db = client.db(process.env.MONGODB_DB);
|
||||
export const getSessionsByUser = async (id: string, limit = 0, filter = {}) =>
|
||||
await db
|
||||
.collection("sessions")
|
||||
.find<Session>({user: id, ...filter})
|
||||
.find<Session>({ user: id, ...filter })
|
||||
.limit(limit || 0)
|
||||
.toArray();
|
||||
|
||||
export const getSessionByAssignment = async (assignmentID: string) =>
|
||||
await db
|
||||
.collection("sessions")
|
||||
.findOne<Session>({"assignment.id": assignmentID})
|
||||
.collection("sessions")
|
||||
.findOne<Session>({ "assignment.id": assignmentID })
|
||||
|
||||
export const getSessionsByAssignments = async (assignmentIDs: string[]) =>
|
||||
await db
|
||||
.collection("sessions")
|
||||
.find<Session>({ "assignment.id": { $in: assignmentIDs } }).toArray()
|
||||
|
||||
Reference in New Issue
Block a user