-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add periodic task for syncing active syncs
- Loading branch information
1 parent
101fa12
commit 54f1056
Showing
8 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import datetime | ||
from typing import List, Optional | ||
|
||
from pydantic import BaseModel | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import asyncio | ||
|
||
from celery_config import celery | ||
from modules.knowledge.repository.storage import Storage | ||
from modules.sync.repository.sync_files import SyncFiles | ||
from modules.sync.service.sync_service import SyncService, SyncUserService | ||
from modules.sync.utils.googleutils import GoogleSyncUtils | ||
|
||
|
||
@celery.task(name="process_sync_active") | ||
def process_sync_active(): | ||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(_process_sync_active()) | ||
|
||
|
||
async def _process_sync_active(): | ||
sync_active_service = SyncService() | ||
sync_user_service = SyncUserService() | ||
sync_files_repo_service = SyncFiles() | ||
storage = Storage() | ||
|
||
google_sync_utils = GoogleSyncUtils( | ||
sync_user_service=sync_user_service, | ||
sync_active_service=sync_active_service, | ||
sync_files_repo=sync_files_repo_service, | ||
storage=storage, | ||
) | ||
active = await sync_active_service.get_syncs_active_in_interval() | ||
|
||
for sync in active: | ||
await google_sync_utils.sync(sync_active_id=sync.id, user_id=sync.user_id) |