This commit is contained in:
@@ -66,18 +66,18 @@ func getBookings(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
tsTo = tsTo.AddDate(0, 0, 1) // so that today is inside
|
||||
|
||||
workDays := models.GetWorkDays(user, tsFrom, tsTo)
|
||||
sort.Slice(workDays, func(i, j int) bool {
|
||||
return workDays[i].Day.After(workDays[j].Day)
|
||||
days := models.GetDays(user, tsFrom, tsTo)
|
||||
sort.Slice(days, func(i, j int) bool {
|
||||
return days[i].Date().After(days[j].Date())
|
||||
})
|
||||
|
||||
lastSub := user.GetLastWorkWeekSubmission()
|
||||
var aggregatedOvertime time.Duration
|
||||
for _, day := range workDays {
|
||||
if day.Day.Before(lastSub) {
|
||||
for _, day := range days {
|
||||
if day.Date().Before(lastSub) {
|
||||
continue
|
||||
}
|
||||
aggregatedOvertime += day.CalcOvertime(user)
|
||||
aggregatedOvertime += day.TimeOvertimeReal(user)
|
||||
}
|
||||
if reportedOvertime, err := user.GetReportedOvertime(); err == nil {
|
||||
user.Overtime = (reportedOvertime + aggregatedOvertime).Round(time.Minute)
|
||||
@@ -88,12 +88,13 @@ func getBookings(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Header.Get("Accept") == "application/json" {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(workDays)
|
||||
json.NewEncoder(w).Encode(days)
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.WithValue(r.Context(), "user", user)
|
||||
templates.TimePage(workDays, lastSub).Render(ctx, w)
|
||||
ctx = context.WithValue(ctx, "days", days)
|
||||
templates.TimePage([]models.WorkDay{}, lastSub).Render(ctx, w)
|
||||
}
|
||||
|
||||
func updateBooking(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user