chore: linting and formatting

This commit is contained in:
DESKTOP-RTLN3BA\$punk 2025-09-28 22:26:26 -07:00
parent ef361e16b4
commit 94367e4226
16 changed files with 143 additions and 131 deletions

View file

@ -428,6 +428,7 @@ async def fetch_documents_by_ids(
try: try:
if "T" in start_time: if "T" in start_time:
from datetime import datetime from datetime import datetime
start_dt = datetime.fromisoformat( start_dt = datetime.fromisoformat(
start_time.replace("Z", "+00:00") start_time.replace("Z", "+00:00")
) )
@ -444,7 +445,7 @@ async def fetch_documents_by_ids(
if location_name: if location_name:
description += f" | Venue: {location_name}" description += f" | Venue: {location_name}"
elif meeting_url: elif meeting_url:
description += f" | Online Event" description += " | Online Event"
url = event_url if event_url else "" url = event_url if event_url else ""

View file

@ -82,7 +82,9 @@ class LumaConnector:
elif response.status_code == 401: elif response.status_code == 401:
raise Exception("Unauthorized: Invalid Luma API key") raise Exception("Unauthorized: Invalid Luma API key")
elif response.status_code == 403: elif response.status_code == 403:
raise Exception("Forbidden: Access denied or Luma Plus subscription required") raise Exception(
"Forbidden: Access denied or Luma Plus subscription required"
)
elif response.status_code == 429: elif response.status_code == 429:
raise Exception("Rate limit exceeded: Too many requests") raise Exception("Rate limit exceeded: Too many requests")
else: else:
@ -106,7 +108,9 @@ class LumaConnector:
except Exception as e: except Exception as e:
return None, f"Error fetching user info: {e!s}" return None, f"Error fetching user info: {e!s}"
def get_all_events(self, limit: int = 100) -> tuple[list[dict[str, Any]], str | None]: def get_all_events(
self, limit: int = 100
) -> tuple[list[dict[str, Any]], str | None]:
""" """
Fetch all events for the authenticated user. Fetch all events for the authenticated user.
@ -134,7 +138,7 @@ class LumaConnector:
all_events.extend(events) all_events.extend(events)
# Check for pagination # Check for pagination
if "next_cursor" in response and response["next_cursor"]: if response.get("next_cursor"):
cursor = response["next_cursor"] cursor = response["next_cursor"]
else: else:
break break
@ -144,7 +148,9 @@ class LumaConnector:
except Exception as e: except Exception as e:
return [], f"Error fetching events: {e!s}" return [], f"Error fetching events: {e!s}"
def get_event_details(self, event_id: str) -> tuple[dict[str, Any] | None, str | None]: def get_event_details(
self, event_id: str
) -> tuple[dict[str, Any] | None, str | None]:
""" """
Fetch detailed information about a specific event. Fetch detailed information about a specific event.
@ -160,7 +166,9 @@ class LumaConnector:
except Exception as e: except Exception as e:
return None, f"Error fetching event details for {event_id}: {e!s}" return None, f"Error fetching event details for {event_id}: {e!s}"
def get_event_guests(self, event_id: str, limit: int = 100) -> tuple[list[dict[str, Any]], str | None]: def get_event_guests(
self, event_id: str, limit: int = 100
) -> tuple[list[dict[str, Any]], str | None]:
""" """
Fetch guests for a specific event. Fetch guests for a specific event.
@ -189,7 +197,7 @@ class LumaConnector:
all_guests.extend(guests) all_guests.extend(guests)
# Check for pagination # Check for pagination
if "next_cursor" in response and response["next_cursor"]: if response.get("next_cursor"):
cursor = response["next_cursor"] cursor = response["next_cursor"]
else: else:
break break
@ -230,7 +238,9 @@ class LumaConnector:
if event_start_time: if event_start_time:
try: try:
# Parse the event start time (assuming ISO format) # Parse the event start time (assuming ISO format)
event_dt = datetime.fromisoformat(event_start_time.replace("Z", "+00:00")) event_dt = datetime.fromisoformat(
event_start_time.replace("Z", "+00:00")
)
event_date = event_dt.date() event_date = event_dt.date()
# Check if event falls within the date range # Check if event falls within the date range
@ -239,7 +249,9 @@ class LumaConnector:
if include_guests: if include_guests:
event_id = event.get("api_id") event_id = event.get("api_id")
if event_id: if event_id:
guests, guest_error = self.get_event_guests(event_id) guests, guest_error = self.get_event_guests(
event_id
)
if not guest_error: if not guest_error:
event["guests"] = guests event["guests"] = guests

View file

@ -4,7 +4,6 @@ from .airtable_add_connector_route import (
router as airtable_add_connector_router, router as airtable_add_connector_router,
) )
from .chats_routes import router as chats_router from .chats_routes import router as chats_router
from .luma_add_connector_route import router as luma_add_connector_router
from .documents_routes import router as documents_router from .documents_routes import router as documents_router
from .google_calendar_add_connector_route import ( from .google_calendar_add_connector_route import (
router as google_calendar_add_connector_router, router as google_calendar_add_connector_router,
@ -14,6 +13,7 @@ from .google_gmail_add_connector_route import (
) )
from .llm_config_routes import router as llm_config_router from .llm_config_routes import router as llm_config_router
from .logs_routes import router as logs_router from .logs_routes import router as logs_router
from .luma_add_connector_route import router as luma_add_connector_router
from .podcasts_routes import router as podcasts_router from .podcasts_routes import router as podcasts_router
from .search_source_connectors_routes import router as search_source_connectors_router from .search_source_connectors_routes import router as search_source_connectors_router
from .search_spaces_routes import router as search_spaces_router from .search_spaces_routes import router as search_spaces_router

View file

@ -1,5 +1,4 @@
import logging import logging
from uuid import UUID
from fastapi import APIRouter, Depends, HTTPException from fastapi import APIRouter, Depends, HTTPException
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
@ -52,7 +51,8 @@ async def add_luma_connector(
result = await session.execute( result = await session.execute(
select(SearchSourceConnector).filter( select(SearchSourceConnector).filter(
SearchSourceConnector.user_id == user.id, SearchSourceConnector.user_id == user.id,
SearchSourceConnector.connector_type == SearchSourceConnectorType.LUMA_CONNECTOR, SearchSourceConnector.connector_type
== SearchSourceConnectorType.LUMA_CONNECTOR,
) )
) )
existing_connector = result.scalars().first() existing_connector = result.scalars().first()
@ -133,7 +133,8 @@ async def delete_luma_connector(
result = await session.execute( result = await session.execute(
select(SearchSourceConnector).filter( select(SearchSourceConnector).filter(
SearchSourceConnector.user_id == user.id, SearchSourceConnector.user_id == user.id,
SearchSourceConnector.connector_type == SearchSourceConnectorType.LUMA_CONNECTOR, SearchSourceConnector.connector_type
== SearchSourceConnectorType.LUMA_CONNECTOR,
) )
) )
connector = result.scalars().first() connector = result.scalars().first()
@ -185,7 +186,8 @@ async def test_luma_connector(
result = await session.execute( result = await session.execute(
select(SearchSourceConnector).filter( select(SearchSourceConnector).filter(
SearchSourceConnector.user_id == user.id, SearchSourceConnector.user_id == user.id,
SearchSourceConnector.connector_type == SearchSourceConnectorType.LUMA_CONNECTOR, SearchSourceConnector.connector_type
== SearchSourceConnectorType.LUMA_CONNECTOR,
) )
) )
connector = result.scalars().first() connector = result.scalars().first()

View file

@ -45,9 +45,9 @@ from app.tasks.connector_indexers import (
index_google_gmail_messages, index_google_gmail_messages,
index_jira_issues, index_jira_issues,
index_linear_issues, index_linear_issues,
index_luma_events,
index_notion_pages, index_notion_pages,
index_slack_messages, index_slack_messages,
index_luma_events
) )
from app.users import current_active_user from app.users import current_active_user
from app.utils.check_ownership import check_ownership from app.utils.check_ownership import check_ownership
@ -1280,6 +1280,7 @@ async def run_google_gmail_indexing(
) )
# Optionally update status in DB to indicate failure # Optionally update status in DB to indicate failure
# Add new helper functions for luma indexing # Add new helper functions for luma indexing
async def run_luma_indexing_with_new_session( async def run_luma_indexing_with_new_session(
connector_id: int, connector_id: int,
@ -1297,6 +1298,7 @@ async def run_luma_indexing_with_new_session(
session, connector_id, search_space_id, user_id, start_date, end_date session, connector_id, search_space_id, user_id, start_date, end_date
) )
async def run_luma_indexing( async def run_luma_indexing(
session: AsyncSession, session: AsyncSession,
connector_id: int, connector_id: int,

View file

@ -1959,6 +1959,7 @@ class ConnectorService:
try: try:
if "T" in end_time: if "T" in end_time:
from datetime import datetime from datetime import datetime
end_dt = datetime.fromisoformat( end_dt = datetime.fromisoformat(
end_time.replace("Z", "+00:00") end_time.replace("Z", "+00:00")
) )

View file

@ -31,10 +31,10 @@ from .github_indexer import index_github_repos
from .google_calendar_indexer import index_google_calendar_events from .google_calendar_indexer import index_google_calendar_events
from .google_gmail_indexer import index_google_gmail_messages from .google_gmail_indexer import index_google_gmail_messages
from .jira_indexer import index_jira_issues from .jira_indexer import index_jira_issues
from .luma_indexer import index_luma_events
# Issue tracking and project management # Issue tracking and project management
from .linear_indexer import index_linear_issues from .linear_indexer import index_linear_issues
from .luma_indexer import index_luma_events
# Documentation and knowledge management # Documentation and knowledge management
from .notion_indexer import index_notion_pages from .notion_indexer import index_notion_pages

View file

@ -84,7 +84,10 @@ async def index_luma_events(
"Connector not found", "Connector not found",
{"error_type": "ConnectorNotFound"}, {"error_type": "ConnectorNotFound"},
) )
return 0, f"Connector with ID {connector_id} not found or is not a Luma connector" return (
0,
f"Connector with ID {connector_id} not found or is not a Luma connector",
)
# Get the Luma API key from the connector config # Get the Luma API key from the connector config
api_key = connector.config.get("LUMA_API_KEY") api_key = connector.config.get("LUMA_API_KEY")
@ -107,9 +110,7 @@ async def index_luma_events(
{"stage": "client_initialization"}, {"stage": "client_initialization"},
) )
luma_client = LumaConnector( luma_client = LumaConnector(api_key=api_key)
api_key=api_key
)
# Calculate date range # Calculate date range
if start_date is None or end_date is None: if start_date is None or end_date is None:
@ -167,9 +168,7 @@ async def index_luma_events(
# Get events within date range from Luma # Get events within date range from Luma
try: try:
events, error = luma_client.get_events_by_date_range( events, error = luma_client.get_events_by_date_range(
start_date_str, start_date_str, end_date_str, include_guests=False
end_date_str,
include_guests=False
) )
if error: if error:
@ -248,7 +247,9 @@ async def index_luma_events(
# Host info # Host info
hosts = event_data.get("hosts", []) hosts = event_data.get("hosts", [])
host_names = ", ".join([host.get("name", "") for host in hosts if host.get("name")]) host_names = ", ".join(
[host.get("name", "") for host in hosts if host.get("name")]
)
description = event_data.get("description", "") description = event_data.get("description", "")
cover_url = event_data.get("cover_url", "") cover_url = event_data.get("cover_url", "")

View file

@ -53,7 +53,7 @@ const getConnectorTypeDisplay = (type: string): string => {
GOOGLE_CALENDAR_CONNECTOR: "Google Calendar Connector", GOOGLE_CALENDAR_CONNECTOR: "Google Calendar Connector",
GOOGLE_GMAIL_CONNECTOR: "Google Gmail Connector", GOOGLE_GMAIL_CONNECTOR: "Google Gmail Connector",
AIRTABLE_CONNECTOR: "Airtable Connector", AIRTABLE_CONNECTOR: "Airtable Connector",
LUMA_CONNECTOR: "Luma Connector" LUMA_CONNECTOR: "Luma Connector",
// Add other connector types here as needed // Add other connector types here as needed
}; };
return typeMap[type] || type; return typeMap[type] || type;
@ -72,7 +72,7 @@ const getApiKeyFieldName = (connectorType: string): string => {
GITHUB_CONNECTOR: "GITHUB_PAT", GITHUB_CONNECTOR: "GITHUB_PAT",
DISCORD_CONNECTOR: "DISCORD_BOT_TOKEN", DISCORD_CONNECTOR: "DISCORD_BOT_TOKEN",
LINKUP_API: "LINKUP_API_KEY", LINKUP_API: "LINKUP_API_KEY",
LUMA_CONNECTOR: "LUMA_API_KEY" LUMA_CONNECTOR: "LUMA_API_KEY",
}; };
return fieldMap[connectorType] || ""; return fieldMap[connectorType] || "";
}; };

View file

@ -69,8 +69,7 @@ export default function LumaConnectorPage() {
useEffect(() => { useEffect(() => {
fetchConnectors().then((data) => { fetchConnectors().then((data) => {
const connector = data.find( const connector = data.find(
(c: SearchSourceConnector) => (c: SearchSourceConnector) => c.connector_type === EnumConnectorName.LUMA_CONNECTOR
c.connector_type === EnumConnectorName.LUMA_CONNECTOR
); );
if (connector) { if (connector) {
setDoesConnectorExist(true); setDoesConnectorExist(true);
@ -86,7 +85,7 @@ export default function LumaConnectorPage() {
name: values.name, name: values.name,
connector_type: EnumConnectorName.LUMA_CONNECTOR, connector_type: EnumConnectorName.LUMA_CONNECTOR,
config: { config: {
LUMA_API_KEY: values.api_key LUMA_API_KEY: values.api_key,
}, },
is_indexable: true, is_indexable: true,
last_indexed_at: null, last_indexed_at: null,
@ -126,9 +125,7 @@ export default function LumaConnectorPage() {
</div> </div>
<div> <div>
<h1 className="text-3xl font-bold tracking-tight">Connect Luma</h1> <h1 className="text-3xl font-bold tracking-tight">Connect Luma</h1>
<p className="text-muted-foreground"> <p className="text-muted-foreground">Connect your Luma account to search events.</p>
Connect your Luma account to search events.
</p>
</div> </div>
</div> </div>
</div> </div>
@ -170,11 +167,7 @@ export default function LumaConnectorPage() {
<FormItem> <FormItem>
<FormLabel>API Key</FormLabel> <FormLabel>API Key</FormLabel>
<FormControl> <FormControl>
<Input <Input type="password" placeholder="Enter your Luma API key" {...field} />
type="password"
placeholder="Enter your Luma API key"
{...field}
/>
</FormControl> </FormControl>
<FormDescription> <FormDescription>
Your API key will be encrypted and stored securely. Your API key will be encrypted and stored securely.

View file

@ -146,7 +146,7 @@ const connectorCategories: ConnectorCategory[] = [
description: "Connect to Luma to search events", description: "Connect to Luma to search events",
icon: getConnectorIcon(EnumConnectorName.LUMA_CONNECTOR, "h-6 w-6"), icon: getConnectorIcon(EnumConnectorName.LUMA_CONNECTOR, "h-6 w-6"),
status: "available", status: "available",
} },
], ],
}, },
{ {

View file

@ -43,6 +43,6 @@ export const editConnectorSchema = z.object({
GOOGLE_CALENDAR_CLIENT_SECRET: z.string().optional(), GOOGLE_CALENDAR_CLIENT_SECRET: z.string().optional(),
GOOGLE_CALENDAR_REFRESH_TOKEN: z.string().optional(), GOOGLE_CALENDAR_REFRESH_TOKEN: z.string().optional(),
GOOGLE_CALENDAR_CALENDAR_IDS: z.string().optional(), GOOGLE_CALENDAR_CALENDAR_IDS: z.string().optional(),
LUMA_API_KEY: z.string().optional() LUMA_API_KEY: z.string().optional(),
}); });
export type EditConnectorFormValues = z.infer<typeof editConnectorSchema>; export type EditConnectorFormValues = z.infer<typeof editConnectorSchema>;

View file

@ -13,5 +13,5 @@ export enum EnumConnectorName {
GOOGLE_CALENDAR_CONNECTOR = "GOOGLE_CALENDAR_CONNECTOR", GOOGLE_CALENDAR_CONNECTOR = "GOOGLE_CALENDAR_CONNECTOR",
GOOGLE_GMAIL_CONNECTOR = "GOOGLE_GMAIL_CONNECTOR", GOOGLE_GMAIL_CONNECTOR = "GOOGLE_GMAIL_CONNECTOR",
AIRTABLE_CONNECTOR = "AIRTABLE_CONNECTOR", AIRTABLE_CONNECTOR = "AIRTABLE_CONNECTOR",
LUMA_CONNECTOR = "LUMA_CONNECTOR" LUMA_CONNECTOR = "LUMA_CONNECTOR",
} }

View file

@ -10,10 +10,10 @@ import {
IconLayoutKanban, IconLayoutKanban,
IconLinkPlus, IconLinkPlus,
IconMail, IconMail,
IconSparkles,
IconTable, IconTable,
IconTicket, IconTicket,
IconWorldWww, IconWorldWww,
IconSparkles,
} from "@tabler/icons-react"; } from "@tabler/icons-react";
import { File, Globe, Link, Microscope, Search, Sparkles, Telescope, Webhook } from "lucide-react"; import { File, Globe, Link, Microscope, Search, Sparkles, Telescope, Webhook } from "lucide-react";
import { EnumConnectorName } from "./connector"; import { EnumConnectorName } from "./connector";

View file

@ -52,7 +52,7 @@ export function useConnectorEditPage(connectorId: number, searchSpaceId: string)
JIRA_BASE_URL: "", JIRA_BASE_URL: "",
JIRA_EMAIL: "", JIRA_EMAIL: "",
JIRA_API_TOKEN: "", JIRA_API_TOKEN: "",
LUMA_API_KEY: "" LUMA_API_KEY: "",
}, },
}); });
@ -79,7 +79,7 @@ export function useConnectorEditPage(connectorId: number, searchSpaceId: string)
JIRA_BASE_URL: config.JIRA_BASE_URL || "", JIRA_BASE_URL: config.JIRA_BASE_URL || "",
JIRA_EMAIL: config.JIRA_EMAIL || "", JIRA_EMAIL: config.JIRA_EMAIL || "",
JIRA_API_TOKEN: config.JIRA_API_TOKEN || "", JIRA_API_TOKEN: config.JIRA_API_TOKEN || "",
LUMA_API_KEY: config.LUMA_API_KEY || "" LUMA_API_KEY: config.LUMA_API_KEY || "",
}); });
if (currentConnector.connector_type === "GITHUB_CONNECTOR") { if (currentConnector.connector_type === "GITHUB_CONNECTOR") {
const savedRepos = config.repo_full_names || []; const savedRepos = config.repo_full_names || [];

View file

@ -15,7 +15,7 @@ export const getConnectorTypeDisplay = (type: string): string => {
GOOGLE_CALENDAR_CONNECTOR: "Google Calendar", GOOGLE_CALENDAR_CONNECTOR: "Google Calendar",
GOOGLE_GMAIL_CONNECTOR: "Google Gmail", GOOGLE_GMAIL_CONNECTOR: "Google Gmail",
AIRTABLE_CONNECTOR: "Airtable", AIRTABLE_CONNECTOR: "Airtable",
LUMA_CONNECTOR: "Luma" LUMA_CONNECTOR: "Luma",
}; };
return typeMap[type] || type; return typeMap[type] || type;
}; };