eflips-depot 4.6.5__py3-none-any.whl → 4.6.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of eflips-depot might be problematic. Click here for more details.

@@ -266,8 +266,18 @@ def simple_consumption_simulation(
266
266
  vehicles = (
267
267
  session.query(Vehicle).filter(Vehicle.scenario_id == scenario.id).all()
268
268
  )
269
+
270
+ # Get the event count for each vbehicle in a single query using a groub_py clause
271
+ vehicle_event_count_q = (
272
+ session.query(Event.vehicle_id, sqlalchemy.func.count(Event.id))
273
+ .join(Vehicle)
274
+ .filter(Vehicle.scenario_id == scenario.id)
275
+ .group_by(Event.vehicle_id)
276
+ )
277
+ vehicle_event_count = dict(vehicle_event_count_q.all())
278
+
269
279
  for vehicle in vehicles:
270
- if session.query(Event).filter(Event.vehicle_id == vehicle.id).count() == 0:
280
+ if vehicle.id not in vehicle_event_count.keys():
271
281
  add_initial_standby_event(vehicle, session)
272
282
 
273
283
  # Since we are doing no_autoflush blocks later, we need to flush the session once here so that unflushed stuff
@@ -78,13 +78,14 @@ def add_initial_standby_event(
78
78
  but changes are not yet committed.
79
79
  """
80
80
 
81
- earliest_trip = (
81
+ earliest_trip_q = (
82
82
  session.query(Trip)
83
83
  .join(Rotation)
84
84
  .filter(Rotation.vehicle == vehicle)
85
85
  .order_by(Trip.departure_time)
86
- .first()
86
+ .limit(1)
87
87
  )
88
+ earliest_trip = earliest_trip_q.one_or_none()
88
89
  if earliest_trip is None:
89
90
  warnings.warn(
90
91
  f"No trips found for vehicle {vehicle.id}. Cannot add initial standby event.",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: eflips-depot
3
- Version: 4.6.5
3
+ Version: 4.6.6
4
4
  Summary: Depot Simulation for eFLIPS
5
5
  License: AGPL-3.0-or-later
6
6
  Author: Enrico Lauth
@@ -1,8 +1,8 @@
1
1
  eflips/depot/__init__.py,sha256=RQ_UKNrGWA6q17TZFu86ai8pC7qCpcbmAgVKh7aImwo,1613
2
- eflips/depot/api/__init__.py,sha256=0ifYtEwSs2LbpPINxdDsGNxdywKRicCQBETB7BpBh9Y,48631
2
+ eflips/depot/api/__init__.py,sha256=4oNT-J3CB34m7cenCbx2Fi1IWFk9rfDG2-TT6EqCU64,49003
3
3
  eflips/depot/api/defaults/default_settings.json,sha256=0eUDTw_rtLQFvthP8oJL93iRXlmAOravAg-4qqGMQAY,5375
4
4
  eflips/depot/api/private/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- eflips/depot/api/private/consumption.py,sha256=vDPCogd3NPx2duCUhg_CcW9rMQWgrppfqsS4E7W9T1Y,16400
5
+ eflips/depot/api/private/consumption.py,sha256=FTF_E-DsbvJNWZJKQy_CPoHQpLz--pWY-inJYg8lsjM,16453
6
6
  eflips/depot/api/private/depot.py,sha256=WcCcib3NSbvoL3G06I2ajT8U5L7AkDK5qe969PHq-fg,41014
7
7
  eflips/depot/api/private/results_to_database.py,sha256=Sh2VJ3k60QJ5RGkc8sw-7XbljiMe65EHeoagKIpYlHM,24585
8
8
  eflips/depot/api/private/smart_charging.py,sha256=MQ9fXdKByHAz6RSKXYcpJXDBccdJKZ2qGReCHagVCyo,13033
@@ -37,7 +37,7 @@ eflips/depot/simulation.py,sha256=ee0qTzOzG-8ybN36ie_NJallXfC7jUaS9JZvaYFziLs,10
37
37
  eflips/depot/smart_charging.py,sha256=C3BYqzn2-OYY4ipXm0ETtavbAM9QXZMYULBpVoChf0E,54311
38
38
  eflips/depot/standalone.py,sha256=VxcTzBaB67fNJUMmjPRwKXjhqTy6oQ41Coote2LvAmk,22338
39
39
  eflips/depot/validation.py,sha256=TIuY7cQtEJI4H2VVMSuY5IIVkacEEZ67weeMuY3NSAM,7097
40
- eflips_depot-4.6.5.dist-info/LICENSE.md,sha256=KB4XTk1fPHjtZCYDyPyreu6h1LVJVZXYg-5vePcWZAc,34143
41
- eflips_depot-4.6.5.dist-info/METADATA,sha256=aPK2OCraATDQr-H1kBZGqyZkj1fC0ZUBecES6EFCyoU,5940
42
- eflips_depot-4.6.5.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
43
- eflips_depot-4.6.5.dist-info/RECORD,,
40
+ eflips_depot-4.6.6.dist-info/LICENSE.md,sha256=KB4XTk1fPHjtZCYDyPyreu6h1LVJVZXYg-5vePcWZAc,34143
41
+ eflips_depot-4.6.6.dist-info/METADATA,sha256=j67zcAG9Xk9dSXsmwe0HPZbTHRTlGYnUTc__Dl-ncLs,5940
42
+ eflips_depot-4.6.6.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
43
+ eflips_depot-4.6.6.dist-info/RECORD,,