diff --git a/orm/response.go b/orm/response.go index 1c1e223c..014dcb48 100644 --- a/orm/response.go +++ b/orm/response.go @@ -227,9 +227,15 @@ func (model *Response) Update(db *Database, args map[string]string, w http.Respo if err := db._db.Model(&response).Update("start_time", time.Now()).Error; err != nil { return nil, err } - if err := db._db.Model(&response).Update("end_time", time.Now().Add(time.Duration(response.Contest.Duration)*time.Minute)).Error; err != nil { + + endTime := time.Now().Add(time.Duration(response.Contest.Duration) * time.Minute) + if endTime.After(response.Contest.EndTime) { + endTime = response.Contest.EndTime + } + if err := db._db.Model(&response).Update("end_time", endTime).Error; err != nil { return nil, err } + log.Println("StartTime/EndTime", response.StartTime, response.EndTime) } response.TimeLeft = response.EndTime.Sub(time.Now())