mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-21 18:55:16 +02:00
fix: fixed linting for some files
This commit is contained in:
parent
82d8320928
commit
e8e393a0d5
4 changed files with 39 additions and 17 deletions
|
|
@ -44,4 +44,4 @@ def downgrade() -> None:
|
|||
Downgrade logic not implemented since PostgreSQL
|
||||
does not support removing enum values.
|
||||
"""
|
||||
pass
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -85,7 +85,9 @@ async def get_editor_content(
|
|||
"title": document.title,
|
||||
"document_type": document.document_type.value,
|
||||
"blocknote_document": empty_blocknote,
|
||||
"updated_at": document.updated_at.isoformat() if document.updated_at else None,
|
||||
"updated_at": document.updated_at.isoformat()
|
||||
if document.updated_at
|
||||
else None,
|
||||
}
|
||||
|
||||
# Lazy migration: Try to generate blocknote_document from chunks (for other document types)
|
||||
|
|
@ -178,18 +180,30 @@ async def save_document(
|
|||
and len(blocknote_document) > 0
|
||||
):
|
||||
first_block = blocknote_document[0]
|
||||
if first_block and first_block.get("content"):
|
||||
if (
|
||||
first_block
|
||||
and first_block.get("content")
|
||||
and isinstance(first_block["content"], list)
|
||||
):
|
||||
# Extract text from first block content
|
||||
# Match the frontend extractTitleFromBlockNote logic exactly
|
||||
title_parts = []
|
||||
for item in first_block["content"]:
|
||||
if isinstance(item, str):
|
||||
title_parts.append(item)
|
||||
elif isinstance(item, dict) and "text" in item:
|
||||
elif (
|
||||
isinstance(item, dict)
|
||||
and "text" in item
|
||||
and isinstance(item["text"], str)
|
||||
):
|
||||
# BlockNote structure: {"type": "text", "text": "...", "styles": {}}
|
||||
title_parts.append(item["text"])
|
||||
|
||||
new_title = "".join(title_parts).strip()
|
||||
if new_title:
|
||||
document.title = new_title
|
||||
else:
|
||||
# Only set to "Untitled" if content exists but is empty
|
||||
document.title = "Untitled"
|
||||
|
||||
# Save BlockNote document
|
||||
|
|
|
|||
|
|
@ -97,7 +97,10 @@ async def create_note(
|
|||
)
|
||||
|
||||
|
||||
@router.get("/search-spaces/{search_space_id}/notes", response_model=PaginatedResponse[DocumentRead])
|
||||
@router.get(
|
||||
"/search-spaces/{search_space_id}/notes",
|
||||
response_model=PaginatedResponse[DocumentRead],
|
||||
)
|
||||
async def list_notes(
|
||||
search_space_id: int,
|
||||
skip: int | None = None,
|
||||
|
|
@ -130,10 +133,12 @@ async def list_notes(
|
|||
|
||||
# Get total count
|
||||
count_query = select(func.count()).select_from(
|
||||
select(Document).where(
|
||||
select(Document)
|
||||
.where(
|
||||
Document.search_space_id == search_space_id,
|
||||
Document.document_type == DocumentType.NOTE,
|
||||
).subquery()
|
||||
)
|
||||
.subquery()
|
||||
)
|
||||
total_result = await session.execute(count_query)
|
||||
total = total_result.scalar() or 0
|
||||
|
|
@ -174,13 +179,17 @@ async def list_notes(
|
|||
]
|
||||
|
||||
# Calculate pagination info
|
||||
actual_skip = skip if skip is not None else (page * page_size if page is not None else 0)
|
||||
actual_skip = (
|
||||
skip if skip is not None else (page * page_size if page is not None else 0)
|
||||
)
|
||||
has_more = (actual_skip + len(items)) < total if page_size > 0 else False
|
||||
|
||||
return PaginatedResponse(
|
||||
items=items,
|
||||
total=total,
|
||||
page=page if page is not None else (actual_skip // page_size if page_size > 0 else 0),
|
||||
page=page
|
||||
if page is not None
|
||||
else (actual_skip // page_size if page_size > 0 else 0),
|
||||
page_size=page_size,
|
||||
has_more=has_more,
|
||||
)
|
||||
|
|
@ -225,4 +234,3 @@ async def delete_note(
|
|||
await session.commit()
|
||||
|
||||
return {"message": "Note deleted successfully", "note_id": note_id}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
"use client";
|
||||
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { AlertCircle, ArrowLeft, FileText, Loader2, Save } from "lucide-react";
|
||||
import { motion } from "motion/react";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { toast } from "sonner";
|
||||
import { BlockNoteEditor } from "@/components/DynamicBlockNoteEditor";
|
||||
import {
|
||||
|
|
@ -217,11 +217,7 @@ export default function EditorPage() {
|
|||
});
|
||||
|
||||
// Update URL to reflect the new document ID without navigation
|
||||
window.history.replaceState(
|
||||
{},
|
||||
"",
|
||||
`/dashboard/${searchSpaceId}/editor/${note.id}`
|
||||
);
|
||||
window.history.replaceState({}, "", `/dashboard/${searchSpaceId}/editor/${note.id}`);
|
||||
// Update document state to reflect the new ID
|
||||
setDocument({
|
||||
document_id: note.id,
|
||||
|
|
@ -323,7 +319,11 @@ export default function EditorPage() {
|
|||
<CardDescription>{error}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Button onClick={() => router.push(`/dashboard/${searchSpaceId}/researcher`)} variant="outline" className="gap-2">
|
||||
<Button
|
||||
onClick={() => router.push(`/dashboard/${searchSpaceId}/researcher`)}
|
||||
variant="outline"
|
||||
className="gap-2"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
Back
|
||||
</Button>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue