Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Methods

_randomTimesPerWeek

  • _randomTimesPerWeek(this: WeekScheduleDoc, subjectsAmount: number): object
  • Returns a number[] of subjectsAmount length and its sum in an object. This array defines the number of times each subject appears in the schedule.

    remarks

    E.g. if subjects: ['Math', 'English', 'Programming'], then subjectsAmount === subjects.length === 3, and this function returns { timesSum: 5, timesPerWeek: [1, 2, 2] } timesPerWeek numbers are genrated randomly according to some restrictions. Returned data means, that 'Math' appears 1 time in a week schedule and 'English' and 'Propgramming' appear 2 times in the schedule.

    Parameters

    • this: WeekScheduleDoc
    • subjectsAmount: number

      Length of times array to generate.

    Returns object

_setRandomSchedule

  • _setRandomSchedule(this: WeekScheduleDoc, subjects: object[]): Promise<void>
  • Core implementation of setRandomSchedule, error checks are supposed to be already done when invoking it.

    Parameters

    • this: WeekScheduleDoc
    • subjects: object[]

      Array of projected AcademicSubjects retrieved from the db.

    Returns Promise<void>

setRandomSchedule

  • Sets subjects to be a random matrix of AcademicSubjectDoc.name. Generates at max Const.MaxSubjectTimesPerWeek entries of subject per week. Does not corrupt state in case of an error. Does not write any changes to the database. As it is a subdocument, it will be saved only with its parent document.

    throws

    NotEnoughSubjectsForScheduleError if there are not enough subjects, registered in the database to make a schedule.

    throws

    ApolloError if a database read/write error occurs.

    Parameters

    Returns Promise<void>

todaySubjects

  • Returns an AcademicSubjectDoc.name[], that denotes the list of today's subjets in schedule.

    throws

    NoScheduleForTodayError if today is Sunday, or schedule is empty (null).

    Parameters

    Returns string[]

Generated using TypeDoc