Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -987,18 +987,9 @@ class DriveWatcher:
|
|
| 987 |
async def startup_event():
|
| 988 |
app.state.drive_watcher = DriveWatcher()
|
| 989 |
|
| 990 |
-
# Initialize Firestore client with explicit credentials
|
| 991 |
-
app.state.firestore_client = firestore.AsyncClient(
|
| 992 |
-
project=firebase_configuration['project_id'],
|
| 993 |
-
credentials=firebase_credentials
|
| 994 |
-
)
|
| 995 |
-
|
| 996 |
-
# Initialize Drive service with explicit credentials
|
| 997 |
-
app.state.drive_service = drive_service
|
| 998 |
-
|
| 999 |
# Fetch all users and initialize the watch list
|
| 1000 |
-
users_ref =
|
| 1001 |
-
users =
|
| 1002 |
for user in users:
|
| 1003 |
user_data = user.to_dict()
|
| 1004 |
if 'gDrive_metadata' in user_data and 'uploaded' in user_data['gDrive_metadata']:
|
|
@@ -1010,6 +1001,8 @@ async def startup_event():
|
|
| 1010 |
# Set up the Firebase listener
|
| 1011 |
app.state.users_watch = users_ref.on_snapshot(app.state.drive_watcher.on_user_change)
|
| 1012 |
|
|
|
|
|
|
|
| 1013 |
|
| 1014 |
@app.on_event("shutdown")
|
| 1015 |
async def shutdown_event():
|
|
|
|
| 987 |
async def startup_event():
|
| 988 |
app.state.drive_watcher = DriveWatcher()
|
| 989 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 990 |
# Fetch all users and initialize the watch list
|
| 991 |
+
users_ref = firestore_client.collection('users')
|
| 992 |
+
users = users_ref.get()
|
| 993 |
for user in users:
|
| 994 |
user_data = user.to_dict()
|
| 995 |
if 'gDrive_metadata' in user_data and 'uploaded' in user_data['gDrive_metadata']:
|
|
|
|
| 1001 |
# Set up the Firebase listener
|
| 1002 |
app.state.users_watch = users_ref.on_snapshot(app.state.drive_watcher.on_user_change)
|
| 1003 |
|
| 1004 |
+
logging.info("Application startup completed")
|
| 1005 |
+
|
| 1006 |
|
| 1007 |
@app.on_event("shutdown")
|
| 1008 |
async def shutdown_event():
|