mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-02 19:55:18 +02:00
feat: Implement Electric SQL replication setup for notifications table
- Added setup_electric_replication function to handle Electric SQL replication for the notifications table during app startup. - Updated alembic migration script to remove direct SQL commands for replication, now managed in app/db.py. - Refactored indexing functions in search_source_connectors_routes to support new start_date and end_date parameters for improved flexibility. - Enhanced Google Gmail indexing task to utilize new date parameters, ensuring better control over indexing periods.
This commit is contained in:
parent
44605749c5
commit
38f907e65b
5 changed files with 151 additions and 176 deletions
|
|
@ -445,31 +445,13 @@ async def _index_google_gmail_messages(
|
|||
end_date: str,
|
||||
):
|
||||
"""Index Google Gmail messages with new session."""
|
||||
from datetime import datetime
|
||||
|
||||
from app.routes.search_source_connectors_routes import (
|
||||
run_google_gmail_indexing,
|
||||
)
|
||||
|
||||
# Parse dates to calculate days_back
|
||||
max_messages = 100
|
||||
days_back = 30 # Default
|
||||
|
||||
if start_date:
|
||||
try:
|
||||
# Parse start_date (format: YYYY-MM-DD)
|
||||
start_dt = datetime.strptime(start_date, "%Y-%m-%d")
|
||||
# Calculate days back from now
|
||||
days_back = (datetime.now() - start_dt).days
|
||||
# Ensure at least 1 day
|
||||
days_back = max(1, days_back)
|
||||
except ValueError:
|
||||
# If parsing fails, use default
|
||||
days_back = 30
|
||||
|
||||
async with get_celery_session_maker()() as session:
|
||||
await run_google_gmail_indexing(
|
||||
session, connector_id, search_space_id, user_id, max_messages, days_back
|
||||
session, connector_id, search_space_id, user_id, start_date, end_date
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue