Skip to content

Fix slot boundary alignment for evaluation window end-time log#280

Merged
MaStr merged 2 commits intoissue-275from
copilot/sub-pr-278-again
Feb 25, 2026
Merged

Fix slot boundary alignment for evaluation window end-time log#280
MaStr merged 2 commits intoissue-275from
copilot/sub-pr-278-again

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

last_time in the "Evaluating next N slots until HH:MM" log was computed from the raw calc_timestamp (e.g. 14:23:45) rather than the start of the current slot, producing an off-boundary, misleading time — especially for 15-minute intervals.

Changes

  • src/batcontrol/logic/default.py: Replace the display_minutes / t0 / t1 computation with slot-aligned arithmetic:
    • slot_start — floor calc_timestamp to the nearest interval_minutes boundary (zero seconds/microseconds)
    • last_timeslot_start + max_slots * interval_minutes, the true end of the evaluation window
# Before (inaccurate — mid-slot offset propagates into result)
display_minutes = (max_slots * self.interval_minutes) - self.interval_minutes
last_time = (calc_timestamp + timedelta(minutes=display_minutes)).strftime("%H:%M")
# At 14:23:45, 3×15-min slots → 14:53 ✗

# After (aligned to slot boundary)
slot_start = calc_timestamp.replace(
    minute=(calc_timestamp.minute // self.interval_minutes) * self.interval_minutes,
    second=0, microsecond=0
)
last_time = (slot_start + timedelta(minutes=max_slots * self.interval_minutes)).strftime("%H:%M")
# At 14:23:45, 3×15-min slots → 15:00 ✓

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>
Copilot AI changed the title [WIP] Update default logic log messages based on feedback Fix slot boundary alignment for evaluation window end-time log Feb 25, 2026
Copilot AI requested a review from MaStr February 25, 2026 11:04
@MaStr MaStr marked this pull request as ready for review February 25, 2026 11:28
@MaStr MaStr merged commit a3f906e into issue-275 Feb 25, 2026
@MaStr MaStr deleted the copilot/sub-pr-278-again branch February 25, 2026 11:28
MaStr added a commit that referenced this pull request Feb 25, 2026
* Fixing wrong debug msg: "hour"

Changeing logic messages from hour to "slots". Adding a message to show interval at the beginning of evaluation

* Changing more messages hours -> slots

* Update docstring to replace "high price hours" with "high price slots"

* Get rid of excessive recharge below threshold mesage

* Fix refactor mistake

* Update src/batcontrol/logic/default.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/batcontrol/logic/default.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/batcontrol/logic/default.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/batcontrol/logic/default.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix PEP8 whitespace: remove extra spaces in parentheses (#279)

* Initial plan

* Fix PEP8 whitespace: remove extra spaces in append(slot) call

Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>

* Fix slot boundary alignment for evaluation window end-time log (#280)

* Initial plan

* Fix last_time calculation to align to slot boundary

Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>

* Add feedback

* Use singal slot in loop over plural form

* Update src/batcontrol/core.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* remove entry message on run()

* Some other cleanups and formatting issues

* Review Feedack added

* Review feedback

* Update src/batcontrol/logic/common.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants