cityssm/attendance-tracking

View on GitHub
database/getAbsenceRecord.ts

Summary

Maintainability
A
0 mins
Test Coverage
import type { AbsenceRecord } from '../types/recordTypes.js'

import { getAbsenceRecords } from './getAbsenceRecords.js'

export async function getAbsenceRecord(
  recordId: string,
  sessionUser: AttendUser
): Promise<AbsenceRecord | undefined> {
  const absenceRecords = await getAbsenceRecords(
    {
      recordId,
      recentOnly: false,
      todayOnly: false
    },
    {},
    sessionUser
  )

  if (absenceRecords.length > 0) {
    return absenceRecords[0]
  }

  return undefined
}