mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-05 13:52:40 +02:00
lint
This commit is contained in:
parent
62d0d8b6db
commit
8b735a492a
4 changed files with 35 additions and 18 deletions
|
|
@ -253,7 +253,9 @@ class TeamsConnector:
|
||||||
access_token = await self._get_valid_token()
|
access_token = await self._get_valid_token()
|
||||||
|
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
url = f"{self.GRAPH_API_BASE}/teams/{team_id}/channels/{channel_id}/messages"
|
url = (
|
||||||
|
f"{self.GRAPH_API_BASE}/teams/{team_id}/channels/{channel_id}/messages"
|
||||||
|
)
|
||||||
|
|
||||||
# Note: The Graph API for channel messages doesn't support $filter parameter
|
# Note: The Graph API for channel messages doesn't support $filter parameter
|
||||||
# We fetch all messages and filter them client-side
|
# We fetch all messages and filter them client-side
|
||||||
|
|
@ -286,7 +288,9 @@ class TeamsConnector:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Parse the ISO 8601 datetime string (already timezone-aware)
|
# Parse the ISO 8601 datetime string (already timezone-aware)
|
||||||
created_at = datetime.fromisoformat(created_at_str.replace('Z', '+00:00'))
|
created_at = datetime.fromisoformat(
|
||||||
|
created_at_str.replace("Z", "+00:00")
|
||||||
|
)
|
||||||
|
|
||||||
# Check if message is within date range
|
# Check if message is within date range
|
||||||
if start_date and created_at < start_date:
|
if start_date and created_at < start_date:
|
||||||
|
|
|
||||||
|
|
@ -343,8 +343,12 @@ async def teams_callback(
|
||||||
|
|
||||||
except IntegrityError as e:
|
except IntegrityError as e:
|
||||||
await session.rollback()
|
await session.rollback()
|
||||||
logger.error("Database integrity error creating Teams connector: %s", str(e))
|
logger.error(
|
||||||
redirect_url = f"{config.NEXT_FRONTEND_URL}/dashboard?error=connector_creation_failed"
|
"Database integrity error creating Teams connector: %s", str(e)
|
||||||
|
)
|
||||||
|
redirect_url = (
|
||||||
|
f"{config.NEXT_FRONTEND_URL}/dashboard?error=connector_creation_failed"
|
||||||
|
)
|
||||||
return RedirectResponse(url=redirect_url)
|
return RedirectResponse(url=redirect_url)
|
||||||
|
|
||||||
except HTTPException:
|
except HTTPException:
|
||||||
|
|
|
||||||
|
|
@ -173,10 +173,14 @@ async def index_teams_messages(
|
||||||
end_datetime = None
|
end_datetime = None
|
||||||
if start_date_str:
|
if start_date_str:
|
||||||
# Parse as naive datetime and make it timezone-aware (UTC)
|
# Parse as naive datetime and make it timezone-aware (UTC)
|
||||||
start_datetime = datetime.strptime(start_date_str, "%Y-%m-%d").replace(tzinfo=UTC)
|
start_datetime = datetime.strptime(start_date_str, "%Y-%m-%d").replace(
|
||||||
|
tzinfo=UTC
|
||||||
|
)
|
||||||
if end_date_str:
|
if end_date_str:
|
||||||
# Parse as naive datetime, set to end of day, and make it timezone-aware (UTC)
|
# Parse as naive datetime, set to end of day, and make it timezone-aware (UTC)
|
||||||
end_datetime = datetime.strptime(end_date_str, "%Y-%m-%d").replace(hour=23, minute=59, second=59, tzinfo=UTC)
|
end_datetime = datetime.strptime(end_date_str, "%Y-%m-%d").replace(
|
||||||
|
hour=23, minute=59, second=59, tzinfo=UTC
|
||||||
|
)
|
||||||
|
|
||||||
# Process each team
|
# Process each team
|
||||||
for team in teams:
|
for team in teams:
|
||||||
|
|
@ -314,8 +318,10 @@ async def index_teams_messages(
|
||||||
chunks = await create_document_chunks(
|
chunks = await create_document_chunks(
|
||||||
combined_document_string
|
combined_document_string
|
||||||
)
|
)
|
||||||
doc_embedding = config.embedding_model_instance.embed(
|
doc_embedding = (
|
||||||
combined_document_string
|
config.embedding_model_instance.embed(
|
||||||
|
combined_document_string
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Update existing document
|
# Update existing document
|
||||||
|
|
@ -337,11 +343,14 @@ async def index_teams_messages(
|
||||||
|
|
||||||
# Delete old chunks and add new ones
|
# Delete old chunks and add new ones
|
||||||
existing_document.chunks = chunks
|
existing_document.chunks = chunks
|
||||||
existing_document.updated_at = get_current_timestamp()
|
existing_document.updated_at = (
|
||||||
|
get_current_timestamp()
|
||||||
|
)
|
||||||
|
|
||||||
documents_indexed += 1
|
documents_indexed += 1
|
||||||
logger.info(
|
logger.info(
|
||||||
"Successfully updated Teams message %s", message_id
|
"Successfully updated Teams message %s",
|
||||||
|
message_id,
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue