mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-24 21:38:09 +02:00
chore: ran linting
This commit is contained in:
parent
5ab672b8ff
commit
e2dd80c604
6 changed files with 48 additions and 72 deletions
|
|
@ -651,9 +651,7 @@ async def index_discord_messages(
|
||||||
# PHASE 2: Process each batch document one by one
|
# PHASE 2: Process each batch document one by one
|
||||||
# Each document transitions: pending → processing → ready/failed
|
# Each document transitions: pending → processing → ready/failed
|
||||||
# =======================================================================
|
# =======================================================================
|
||||||
logger.info(
|
logger.info(f"Phase 2: Processing {len(batches_to_process)} batch documents")
|
||||||
f"Phase 2: Processing {len(batches_to_process)} batch documents"
|
|
||||||
)
|
|
||||||
|
|
||||||
for item in batches_to_process:
|
for item in batches_to_process:
|
||||||
# Send heartbeat periodically
|
# Send heartbeat periodically
|
||||||
|
|
|
||||||
|
|
@ -357,9 +357,7 @@ async def index_slack_messages(
|
||||||
# Group messages into batches of SLACK_BATCH_SIZE
|
# Group messages into batches of SLACK_BATCH_SIZE
|
||||||
# Each batch becomes a single document with conversation context
|
# Each batch becomes a single document with conversation context
|
||||||
# =======================================================
|
# =======================================================
|
||||||
for batch_start in range(
|
for batch_start in range(0, len(formatted_messages), SLACK_BATCH_SIZE):
|
||||||
0, len(formatted_messages), SLACK_BATCH_SIZE
|
|
||||||
):
|
|
||||||
batch = formatted_messages[
|
batch = formatted_messages[
|
||||||
batch_start : batch_start + SLACK_BATCH_SIZE
|
batch_start : batch_start + SLACK_BATCH_SIZE
|
||||||
]
|
]
|
||||||
|
|
@ -377,9 +375,7 @@ async def index_slack_messages(
|
||||||
# channel_id + first message ts + last message ts
|
# channel_id + first message ts + last message ts
|
||||||
first_msg_ts = batch[0].get("timestamp", "")
|
first_msg_ts = batch[0].get("timestamp", "")
|
||||||
last_msg_ts = batch[-1].get("timestamp", "")
|
last_msg_ts = batch[-1].get("timestamp", "")
|
||||||
unique_identifier = (
|
unique_identifier = f"{channel_id}_{first_msg_ts}_{last_msg_ts}"
|
||||||
f"{channel_id}_{first_msg_ts}_{last_msg_ts}"
|
|
||||||
)
|
|
||||||
unique_identifier_hash = generate_unique_identifier_hash(
|
unique_identifier_hash = generate_unique_identifier_hash(
|
||||||
DocumentType.SLACK_CONNECTOR,
|
DocumentType.SLACK_CONNECTOR,
|
||||||
unique_identifier,
|
unique_identifier,
|
||||||
|
|
@ -392,10 +388,8 @@ async def index_slack_messages(
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check if document with this unique identifier already exists
|
# Check if document with this unique identifier already exists
|
||||||
existing_document = (
|
existing_document = await check_document_by_unique_identifier(
|
||||||
await check_document_by_unique_identifier(
|
session, unique_identifier_hash
|
||||||
session, unique_identifier_hash
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if existing_document:
|
if existing_document:
|
||||||
|
|
@ -405,9 +399,7 @@ async def index_slack_messages(
|
||||||
if not DocumentStatus.is_state(
|
if not DocumentStatus.is_state(
|
||||||
existing_document.status, DocumentStatus.READY
|
existing_document.status, DocumentStatus.READY
|
||||||
):
|
):
|
||||||
existing_document.status = (
|
existing_document.status = DocumentStatus.ready()
|
||||||
DocumentStatus.ready()
|
|
||||||
)
|
|
||||||
documents_skipped += 1
|
documents_skipped += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -440,10 +432,8 @@ async def index_slack_messages(
|
||||||
# Document doesn't exist by unique_identifier_hash
|
# Document doesn't exist by unique_identifier_hash
|
||||||
# Check if a document with the same content_hash exists (from another connector)
|
# Check if a document with the same content_hash exists (from another connector)
|
||||||
with session.no_autoflush:
|
with session.no_autoflush:
|
||||||
duplicate_by_content = (
|
duplicate_by_content = await check_duplicate_document_by_hash(
|
||||||
await check_duplicate_document_by_hash(
|
session, content_hash
|
||||||
session, content_hash
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if duplicate_by_content:
|
if duplicate_by_content:
|
||||||
|
|
@ -496,12 +486,8 @@ async def index_slack_messages(
|
||||||
"channel_id": channel_id,
|
"channel_id": channel_id,
|
||||||
"first_message_ts": first_msg_ts,
|
"first_message_ts": first_msg_ts,
|
||||||
"last_message_ts": last_msg_ts,
|
"last_message_ts": last_msg_ts,
|
||||||
"first_message_time": batch[0].get(
|
"first_message_time": batch[0].get("datetime", "Unknown"),
|
||||||
"datetime", "Unknown"
|
"last_message_time": batch[-1].get("datetime", "Unknown"),
|
||||||
),
|
|
||||||
"last_message_time": batch[-1].get(
|
|
||||||
"datetime", "Unknown"
|
|
||||||
),
|
|
||||||
"message_count": len(batch),
|
"message_count": len(batch),
|
||||||
"start_date": start_date_str,
|
"start_date": start_date_str,
|
||||||
"end_date": end_date_str,
|
"end_date": end_date_str,
|
||||||
|
|
@ -538,9 +524,7 @@ async def index_slack_messages(
|
||||||
# PHASE 2: Process each batch document one by one
|
# PHASE 2: Process each batch document one by one
|
||||||
# Each document transitions: pending → processing → ready/failed
|
# Each document transitions: pending → processing → ready/failed
|
||||||
# =======================================================================
|
# =======================================================================
|
||||||
logger.info(
|
logger.info(f"Phase 2: Processing {len(batches_to_process)} batch documents")
|
||||||
f"Phase 2: Processing {len(batches_to_process)} batch documents"
|
|
||||||
)
|
|
||||||
|
|
||||||
for item in batches_to_process:
|
for item in batches_to_process:
|
||||||
# Send heartbeat periodically
|
# Send heartbeat periodically
|
||||||
|
|
@ -621,9 +605,7 @@ async def index_slack_messages(
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
await session.commit()
|
await session.commit()
|
||||||
logger.info(
|
logger.info("Successfully committed all Slack document changes to database")
|
||||||
"Successfully committed all Slack document changes to database"
|
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Handle any remaining integrity errors gracefully (race conditions, etc.)
|
# Handle any remaining integrity errors gracefully (race conditions, etc.)
|
||||||
if (
|
if (
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,7 @@ export function RowActions({
|
||||||
document.status?.state === "pending" || document.status?.state === "processing";
|
document.status?.state === "pending" || document.status?.state === "processing";
|
||||||
|
|
||||||
// FILE documents that failed processing cannot be edited
|
// FILE documents that failed processing cannot be edited
|
||||||
const isFileFailed =
|
const isFileFailed = document.document_type === "FILE" && document.status?.state === "failed";
|
||||||
document.document_type === "FILE" && document.status?.state === "failed";
|
|
||||||
|
|
||||||
// SURFSENSE_DOCS are system-managed and should not show delete at all
|
// SURFSENSE_DOCS are system-managed and should not show delete at all
|
||||||
const shouldShowDelete = !NON_DELETABLE_DOCUMENT_TYPES.includes(
|
const shouldShowDelete = !NON_DELETABLE_DOCUMENT_TYPES.includes(
|
||||||
|
|
@ -212,7 +211,8 @@ export function RowActions({
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>Delete document?</AlertDialogTitle>
|
<AlertDialogTitle>Delete document?</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
This action cannot be undone. This will permanently delete this document from your search space.
|
This action cannot be undone. This will permanently delete this document from your
|
||||||
|
search space.
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,9 @@ export function UserDropdown({
|
||||||
className="text-xs md:text-sm"
|
className="text-xs md:text-sm"
|
||||||
disabled={isLoggingOut}
|
disabled={isLoggingOut}
|
||||||
>
|
>
|
||||||
{isLoggingOut ? (
|
{isLoggingOut ? (
|
||||||
<Spinner size="sm" className="mr-2" />
|
<Spinner size="sm" className="mr-2" />
|
||||||
) : (
|
) : (
|
||||||
<LogOut className="mr-2 h-3.5 w-3.5 md:h-4 md:w-4" />
|
<LogOut className="mr-2 h-3.5 w-3.5 md:h-4 md:w-4" />
|
||||||
)}
|
)}
|
||||||
{isLoggingOut ? "Logging out..." : "Log out"}
|
{isLoggingOut ? "Logging out..." : "Log out"}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import { Check, ChevronUp, Languages, Laptop, LogOut, Moon, Settings, Sun } from "lucide-react";
|
||||||
Check,
|
|
||||||
ChevronUp,
|
|
||||||
Languages,
|
|
||||||
Laptop,
|
|
||||||
LogOut,
|
|
||||||
Moon,
|
|
||||||
Settings,
|
|
||||||
Sun,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import {
|
import {
|
||||||
|
|
@ -264,18 +255,18 @@ export function SidebarUserProfile({
|
||||||
|
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
|
|
||||||
<DropdownMenuItem onClick={handleLogout} disabled={isLoggingOut}>
|
<DropdownMenuItem onClick={handleLogout} disabled={isLoggingOut}>
|
||||||
{isLoggingOut ? (
|
{isLoggingOut ? (
|
||||||
<Spinner size="sm" className="mr-2" />
|
<Spinner size="sm" className="mr-2" />
|
||||||
) : (
|
) : (
|
||||||
<LogOut className="mr-2 h-4 w-4" />
|
<LogOut className="mr-2 h-4 w-4" />
|
||||||
)}
|
)}
|
||||||
{isLoggingOut ? t("loggingOut") : t("logout")}
|
{isLoggingOut ? t("loggingOut") : t("logout")}
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expanded view
|
// Expanded view
|
||||||
|
|
@ -386,16 +377,16 @@ export function SidebarUserProfile({
|
||||||
|
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
|
|
||||||
<DropdownMenuItem onClick={handleLogout} disabled={isLoggingOut}>
|
<DropdownMenuItem onClick={handleLogout} disabled={isLoggingOut}>
|
||||||
{isLoggingOut ? (
|
{isLoggingOut ? (
|
||||||
<Spinner size="sm" className="mr-2" />
|
<Spinner size="sm" className="mr-2" />
|
||||||
) : (
|
) : (
|
||||||
<LogOut className="mr-2 h-4 w-4" />
|
<LogOut className="mr-2 h-4 w-4" />
|
||||||
)}
|
)}
|
||||||
{isLoggingOut ? t("loggingOut") : t("logout")}
|
{isLoggingOut ? t("loggingOut") : t("logout")}
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,12 @@ export function PublicChatFooter({ shareToken }: PublicChatFooterProps) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed bottom-6 left-1/2 z-50 -translate-x-1/2">
|
<div className="fixed bottom-6 left-1/2 z-50 -translate-x-1/2">
|
||||||
<Button size="lg" onClick={handleCopyAndContinue} disabled={isCloning} className="gap-2 rounded-full px-6 shadow-lg transition-all duration-200 hover:scale-[1.02] hover:shadow-xl hover:brightness-110 hover:bg-primary">
|
<Button
|
||||||
|
size="lg"
|
||||||
|
onClick={handleCopyAndContinue}
|
||||||
|
disabled={isCloning}
|
||||||
|
className="gap-2 rounded-full px-6 shadow-lg transition-all duration-200 hover:scale-[1.02] hover:shadow-xl hover:brightness-110 hover:bg-primary"
|
||||||
|
>
|
||||||
{isCloning ? <Spinner size="sm" /> : <Copy className="size-4" />}
|
{isCloning ? <Spinner size="sm" /> : <Copy className="size-4" />}
|
||||||
Copy and continue this chat
|
Copy and continue this chat
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue