diff --git a/backend/src/dao/InterviewSlotDao.ts b/backend/src/dao/InterviewSlotDao.ts index 123734100..a78efb705 100644 --- a/backend/src/dao/InterviewSlotDao.ts +++ b/backend/src/dao/InterviewSlotDao.ts @@ -4,6 +4,11 @@ import { DBInterviewSlot } from '../types/DataTypes'; import { getMemberFromDocumentReference } from '../utils/memberUtil'; import BaseDao from './BaseDao'; +/** + * Serializes an InterviewSlot instance into a format suitable for Firestore storage. + * @param {InterviewSlot} instance - The InterviewSlot instance to serialize. + * @returns {Promise} - The serialized InterviewSlot object. + */ async function serializeInterviewSlot(instance: InterviewSlot): Promise { return { ...instance, @@ -12,6 +17,11 @@ async function serializeInterviewSlot(instance: InterviewSlot): Promise} - The materialized InterviewSlot object. + */ async function materializeInterviewSlot(dbInstance: DBInterviewSlot): Promise { return { ...dbInstance, @@ -22,21 +32,39 @@ async function materializeInterviewSlot(dbInstance: DBInterviewSlot): Promise { constructor() { super(interviewSlotCollection, materializeInterviewSlot, serializeInterviewSlot); } + /** + * Retrieves all interview slots associated with a given scheduler UUID. + * @param {string} uuid - The UUID of the interview scheduler. + * @returns {Promise} - A list of InterviewSlot objects. + */ async getSlotsForScheduler(uuid: string): Promise { return this.getDocuments([ { field: 'interviewSchedulerUuid', comparisonOperator: '==', value: uuid } ]); } + /** + * Retrieves a specific interview slot by its UUID. + * @param {string} uuid - The UUID of the interview slot. + * @returns {Promise} - The InterviewSlot object if found, otherwise null. + */ async getSlot(uuid: string): Promise { return this.getDocument(uuid); } + /** + * Adds multiple interview slots to the database. + * @param {InterviewSlot[]} slots - The list of InterviewSlot objects to add. + * @returns {Promise} - The list of created InterviewSlot objects. + */ async addSlots(slots: InterviewSlot[]): Promise { return Promise.all( slots.map((slot) => { @@ -49,6 +77,12 @@ export default class InterviewSlotDao extends BaseDao} - True if the update was successful, false otherwise. + */ async updateSlot(updatedSlot: InterviewSlot, adminBypass: boolean): Promise { const wasUpdated: boolean = await db.runTransaction(async (t) => { const query = this.collection.where('uuid', '==', updatedSlot.uuid); @@ -75,6 +109,11 @@ export default class InterviewSlotDao extends BaseDao} - Resolves when the deletion is complete. + */ async deleteSlot(uuid: string): Promise { return this.deleteDocument(uuid); }