Added tests, shift 'delete'. Fixed overnight shifts, sync, error handling.
This commit is contained in:
parent
c9180490a4
commit
f2aa04db15
20 changed files with 2521 additions and 39 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
|
@ -87,15 +88,12 @@ func (app *App) handleKioskClaim(w http.ResponseWriter, r *http.Request) {
|
|||
writeError(w, "shift not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if shift.Capacity > 0 {
|
||||
count, _ := app.shiftAssignedCount(shiftID)
|
||||
if count >= shift.Capacity {
|
||||
|
||||
if err := app.assignShiftWithCapacity(v.ID, shiftID, shift.Capacity); err != nil {
|
||||
if errors.Is(err, errShiftFull) {
|
||||
writeError(w, "shift is full", http.StatusConflict)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err := app.assignShift(v.ID, shiftID); err != nil {
|
||||
writeError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue