Skip to content

Commit a2a46ca

Browse files
committed
Make generateAIschedule use closest location
1 parent 9124ef9 commit a2a46ca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

server/logic.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,12 +769,12 @@ export class Logic {
769769
}
770770
}
771771

772-
private async generateAIschedule(vehicle: DBVehicle): Promise<{ ts: number; level: number } | null> {
772+
private async generateAIschedule(vehicle: DBVehicle, location_uuid: string | null): Promise<{ ts: number; level: number } | null> {
773773
/*
774774
****** ANALYSE AND THINK ABOUT IT! ******
775775
*/
776776

777-
const locationSettings = this.getVehicleLocationSettings(vehicle, vehicle.location_uuid);
777+
const locationSettings = this.getVehicleLocationSettings(vehicle, location_uuid);
778778
const minimum_charge = locationSettings.directLevel;
779779

780780
const guess: { charge: number; before: number; } | null = await this.db.pg.oneOrNone(
@@ -835,7 +835,7 @@ export class Logic {
835835
`,
836836
[
837837
vehicle.vehicle_uuid,
838-
vehicle.location_uuid,
838+
location_uuid,
839839
null /*scheduleMap[ScheduleType.Guide] &&
840840
scheduleMap[ScheduleType.Guide].time*/,
841841
]
@@ -1097,7 +1097,7 @@ export class Logic {
10971097
if (location_uuid) {
10981098
if (startLevel < vehicle.maximum_charge) {
10991099
// Generate an AI schedule
1100-
const schedule = stats && (await this.generateAIschedule(vehicle));
1100+
const schedule = stats && (await this.generateAIschedule(vehicle, location_uuid));
11011101
// If we have a trip and ai.ts and schedule.ts is more than 12 hours apart, we should still AI charge
11021102
if (!trip || !trip.schedule_ts || trip.schedule_ts.getTime() > priceAvailable
11031103
|| (schedule && Math.abs(trip.schedule_ts.getTime() - schedule.ts) > 12 * 60 * 60e3)

0 commit comments

Comments
 (0)