Skip to content

Commit b572e22

Browse files
fix: Added get_pilot_by_id
1 parent 90acb3b commit b572e22

File tree

1 file changed

+9
-5
lines changed
  • diracx-db/src/diracx/db/sql/pilot_agents

1 file changed

+9
-5
lines changed

diracx-db/src/diracx/db/sql/pilot_agents/db.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,19 @@ async def add_pilot_credentials(self, pilot_id: int) -> str:
190190
return random_secret
191191

192192
async def get_pilots(self):
193-
"""Récupère tous les pilotes et les retourne sous forme de dictionnaires.
194-
195-
:raises: NoResultFound
196-
"""
197-
# La clause with_for_update empêche que le jeton soit récupéré plusieurs fois simultanément
198193
stmt = select(PilotRegistrations).with_for_update()
199194
result = await self.conn.execute(stmt)
200195

201196
# Convertir les résultats en dictionnaires
202197
pilots = [dict(row._mapping) for row in result]
203198

204199
return pilots
200+
201+
async def get_pilot_by_id(self, pilot_id: int):
202+
stmt = (
203+
select(PilotRegistrations)
204+
.with_for_update()
205+
.where(PilotRegistrations.pilot_id == pilot_id)
206+
)
207+
208+
return dict((await self.conn.execute(stmt)).one()._mapping)

0 commit comments

Comments
 (0)