Ändere Wochenfeld von Auswahl "Jede/gerade Vorlesungswochen/ungerade Vorlesungswochen" zu Freitextfeld mit Vorschlag.
Closes #28
This commit is contained in:
parent
5e954ca751
commit
deced3e596
10 changed files with 35 additions and 41 deletions
|
@ -157,7 +157,8 @@ func (r *OfficeHourRepo) Delete(officeHour models.OfficeHour) error {
|
|||
|
||||
func (r *OfficeHourRepo) getFromRow(row *sql.Row) (models.OfficeHour, error) {
|
||||
var officeHour models.OfficeHour
|
||||
var week, day, hour, minute, tutorId, courseId, roomId int
|
||||
var day, hour, minute, tutorId, courseId, roomId int
|
||||
var week string
|
||||
err := row.Scan(&officeHour.Id, &tutorId, &day, &hour, &minute, &roomId, &officeHour.RoomName, &courseId, &week, &officeHour.Info, &officeHour.Active, &officeHour.Duration)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error getting single officeHour row from database: %w", err)
|
||||
|
@ -190,7 +191,8 @@ func (r *OfficeHourRepo) getFromRows(rows *sql.Rows) ([]models.OfficeHour, error
|
|||
var officeHours []models.OfficeHour
|
||||
for rows.Next() {
|
||||
var officeHour models.OfficeHour
|
||||
var week, day, hour, minute, tutorId, roomId, courseId int
|
||||
var day, hour, minute, tutorId, roomId, courseId int
|
||||
var week string
|
||||
var err error
|
||||
if err := rows.Scan(&officeHour.Id, &tutorId, &day, &hour, &minute, &roomId, &officeHour.RoomName, &courseId, &week, &officeHour.Info, &officeHour.Active, &officeHour.Duration); err != nil {
|
||||
return officeHours, fmt.Errorf("error getting multiple officeHour rows from database: %w", err)
|
||||
|
@ -245,9 +247,7 @@ func (r *OfficeHourRepo) NumberByTimeSpanAndRoom(date models.Date, duration int,
|
|||
for _, officeHour := range officeHours {
|
||||
// increase count if officehour starts before this point in time and ends later
|
||||
if models.DateLess(officeHour.Date, models.GetEndDate(date, minute, false)) && models.DateLess(models.GetEndDate(date, minute, false), models.GetEndDate(officeHour.Date, officeHour.Duration, false)) {
|
||||
if date.Week == 0 || officeHour.Week == 0 || date.Week == officeHour.Week { // office hours in alternating weeks should not collide
|
||||
minuteCount += 1
|
||||
}
|
||||
minuteCount += 1
|
||||
}
|
||||
}
|
||||
if minuteCount > count {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue