Update app.py
Browse files
app.py
CHANGED
|
@@ -325,6 +325,24 @@ async def track_order(user_id: str, order_id: str) -> str:
|
|
| 325 |
response += f"\n{eta}"
|
| 326 |
return response
|
| 327 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
async def update_user_profile_with_order(user_id: str, order_id: str):
|
| 329 |
async with async_session() as session:
|
| 330 |
result = await session.execute(
|
|
|
|
| 325 |
response += f"\n{eta}"
|
| 326 |
return response
|
| 327 |
|
| 328 |
+
async def update_user_profile(user_id: str, phone_number: str = None, address: str = None):
|
| 329 |
+
async with async_session() as session:
|
| 330 |
+
result = await session.execute(
|
| 331 |
+
select(UserProfile).where(UserProfile.user_id == user_id)
|
| 332 |
+
)
|
| 333 |
+
profile = result.scalars().first()
|
| 334 |
+
if profile:
|
| 335 |
+
if phone_number:
|
| 336 |
+
profile.phone_number = phone_number
|
| 337 |
+
if address:
|
| 338 |
+
# Assuming you have an address field; if not, you can add one or update a different field.
|
| 339 |
+
profile.address = address
|
| 340 |
+
else:
|
| 341 |
+
profile = UserProfile(user_id=user_id, phone_number=phone_number)
|
| 342 |
+
session.add(profile)
|
| 343 |
+
await session.commit()
|
| 344 |
+
|
| 345 |
+
|
| 346 |
async def update_user_profile_with_order(user_id: str, order_id: str):
|
| 347 |
async with async_session() as session:
|
| 348 |
result = await session.execute(
|