Skip to content

Commit 2f77832

Browse files
committed
Still do AI charging (or even learning) if trip is too far in the future
1 parent 35aff6c commit 2f77832

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

server/logic.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,11 +1091,10 @@ export class Logic {
10911091
if (startLevel < vehicle.maximum_charge) {
10921092
// Generate an AI schedule
10931093
const schedule = stats && (await this.generateAIschedule(vehicle));
1094-
1095-
// If we have a trip and ai.ts and schedule.ts is more than 10 hours apart, we should still AI charge
1096-
if (!trip || !trip.schedule_ts || (
1097-
schedule && Math.abs(trip.schedule_ts.getTime() - schedule.ts) > 10 * 60 * 60e3
1098-
)) {
1094+
// If we have a trip and ai.ts and schedule.ts is more than 12 hours apart, we should still AI charge
1095+
if (!trip || !trip.schedule_ts || trip.schedule_ts.getTime() > priceAvailable
1096+
|| (schedule && Math.abs(trip.schedule_ts.getTime() - schedule.ts) > 12 * 60 * 60e3)
1097+
) {
10991098
ai.charge = true;
11001099

11011100
if (schedule) {

0 commit comments

Comments
 (0)