fix(backend): align weekly reset calculation with Sunday midnight UTC
This commit is contained in:
@@ -53,11 +53,19 @@ calculate_reset() {
|
||||
previous_calibrated="$(printf '%s' "$STATE_JSON" | jq -r --arg n "$name" '.[$n].calibrated // false')"
|
||||
detected="$(jq -n --argjson old "$previous_usage" --argjson new "$current_usage" --argjson oldreq "$previous_req" --argjson newreq "$current_req" '($old != null and (($new < ($old - 0.02)) or ($newreq < $oldreq)))')"
|
||||
|
||||
if [ "$previous_reset" -le 0 ]; then
|
||||
if [ "$name" = "weekly" ] && [ "$previous_reset" -le 0 ]; then
|
||||
# Ollama Cloud weekly reset avviene a mezzanotte UTC (inizio lunedì UTC).
|
||||
RESET_AT="$(date -u -d "next Monday 00:00:00" +%s 2>/dev/null || echo "$((NOW + duration))")"
|
||||
CALIBRATED=true
|
||||
elif [ "$previous_reset" -le 0 ]; then
|
||||
RESET_AT=$((NOW + duration))
|
||||
CALIBRATED=false
|
||||
elif [ "$detected" = true ]; then
|
||||
RESET_AT=$((NOW + duration))
|
||||
if [ "$name" = "weekly" ]; then
|
||||
RESET_AT="$(date -u -d "next Monday 00:00:00" +%s 2>/dev/null || echo "$((NOW + duration))")"
|
||||
else
|
||||
RESET_AT=$((NOW + duration))
|
||||
fi
|
||||
CALIBRATED=true
|
||||
else
|
||||
RESET_AT="$previous_reset"
|
||||
|
||||
Reference in New Issue
Block a user