Verbessere Dokumentation

This commit is contained in:
Gonne 2022-11-04 21:15:38 +01:00
parent ec24c6c4dc
commit fe54d76ab2
14 changed files with 75 additions and 34 deletions

View file

@ -89,6 +89,10 @@ func (r *OfficeHourRepo) FindById(id int) (models.OfficeHour, error) {
return r.getFromRow(r.db.QueryRow("SELECT * FROM officeHour WHERE id=?", id))
}
// Add an office hour if it doesn't exist yet.
// Also add the incluyey tutor if it doesn't exist yet.
//
// Returns the id of the new office hour.
func (r *OfficeHourRepo) Add(officeHour models.OfficeHour) (int, error) {
// Find correct tutor or add if not existent
_, err := r.tutorRepo.Add(officeHour.Tutor)
@ -215,6 +219,7 @@ func (r *OfficeHourRepo) getFromRows(rows *sql.Rows) ([]models.OfficeHour, error
return officeHours, nil
}
// Get the number of office hours that are maximally parallel during a time span.
func (r *OfficeHourRepo) NumberByTimeSpanAndRoom(date models.Date, duration int, room models.Room, activeOnly bool) (int, error) {
var rows *sql.Rows
var err error
@ -252,6 +257,7 @@ func (r *OfficeHourRepo) NumberByTimeSpanAndRoom(date models.Date, duration int,
return count, nil
}
// Check whether the room capacity allows for another office hour during a time span.
func (r *OfficeHourRepo) AllowedAt(date models.Date, duration int, room models.Room, activeOnly bool) (bool, error) {
numberOfOfficeHours, err := r.NumberByTimeSpanAndRoom(date, duration, room, activeOnly)
if err != nil {