mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-06 22:12:12 +02:00
Merge commit '683a7d3bc2' into feat/rename-searchspace-to-workspace
This commit is contained in:
commit
2836654701
27 changed files with 543 additions and 323 deletions
|
|
@ -16,35 +16,48 @@ depends_on: str | Sequence[str] | None = None
|
|||
|
||||
def upgrade() -> None:
|
||||
op.execute(
|
||||
"ALTER TABLE refresh_tokens "
|
||||
"ADD COLUMN IF NOT EXISTS revoked_at TIMESTAMP WITH TIME ZONE"
|
||||
"ALTER TABLE refresh_tokens ADD COLUMN IF NOT EXISTS "
|
||||
"revoked_at TIMESTAMP WITH TIME ZONE"
|
||||
)
|
||||
op.execute(
|
||||
"ALTER TABLE refresh_tokens "
|
||||
"ADD COLUMN IF NOT EXISTS absolute_expiry TIMESTAMP WITH TIME ZONE"
|
||||
"ALTER TABLE refresh_tokens ADD COLUMN IF NOT EXISTS "
|
||||
"absolute_expiry TIMESTAMP WITH TIME ZONE"
|
||||
)
|
||||
|
||||
bind = op.get_bind()
|
||||
is_revoked_exists = bind.execute(
|
||||
sa.text(
|
||||
"""
|
||||
SELECT EXISTS (
|
||||
SELECT FROM information_schema.columns
|
||||
WHERE table_schema = current_schema()
|
||||
AND table_name = 'refresh_tokens'
|
||||
AND column_name = 'is_revoked'
|
||||
)
|
||||
"""
|
||||
)
|
||||
).scalar()
|
||||
|
||||
if is_revoked_exists:
|
||||
op.execute(
|
||||
"""
|
||||
UPDATE refresh_tokens
|
||||
SET revoked_at = NOW()
|
||||
WHERE is_revoked = TRUE
|
||||
AND revoked_at IS NULL
|
||||
"""
|
||||
)
|
||||
|
||||
op.execute(
|
||||
"""
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'refresh_tokens'
|
||||
AND column_name = 'is_revoked'
|
||||
) THEN
|
||||
UPDATE refresh_tokens SET revoked_at = NOW() WHERE is_revoked = TRUE;
|
||||
END IF;
|
||||
END $$;
|
||||
"""
|
||||
"ALTER TABLE refresh_tokens ALTER COLUMN token_hash TYPE VARCHAR(64)"
|
||||
)
|
||||
op.execute("ALTER TABLE refresh_tokens ALTER COLUMN token_hash TYPE VARCHAR(64)")
|
||||
op.execute("ALTER TABLE refresh_tokens DROP COLUMN IF EXISTS is_revoked")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.execute(
|
||||
"ALTER TABLE refresh_tokens "
|
||||
"ADD COLUMN IF NOT EXISTS is_revoked BOOLEAN NOT NULL DEFAULT false"
|
||||
"ALTER TABLE refresh_tokens ADD COLUMN IF NOT EXISTS "
|
||||
"is_revoked BOOLEAN NOT NULL DEFAULT false"
|
||||
)
|
||||
op.execute(
|
||||
"""
|
||||
|
|
@ -61,6 +74,8 @@ def downgrade() -> None:
|
|||
"""
|
||||
)
|
||||
op.execute("ALTER TABLE refresh_tokens ALTER COLUMN is_revoked DROP DEFAULT")
|
||||
op.execute("ALTER TABLE refresh_tokens ALTER COLUMN token_hash TYPE VARCHAR(256)")
|
||||
op.execute(
|
||||
"ALTER TABLE refresh_tokens ALTER COLUMN token_hash TYPE VARCHAR(256)"
|
||||
)
|
||||
op.execute("ALTER TABLE refresh_tokens DROP COLUMN IF EXISTS absolute_expiry")
|
||||
op.execute("ALTER TABLE refresh_tokens DROP COLUMN IF EXISTS revoked_at")
|
||||
|
|
|
|||
|
|
@ -762,7 +762,7 @@ class Config:
|
|||
TURNSTILE_SECRET_KEY = os.getenv("TURNSTILE_SECRET_KEY", "")
|
||||
|
||||
# Auth
|
||||
AUTH_TYPE = os.getenv("AUTH_TYPE")
|
||||
AUTH_TYPE = os.getenv("AUTH_TYPE", "LOCAL")
|
||||
REGISTRATION_ENABLED = os.getenv("REGISTRATION_ENABLED", "TRUE").upper() == "TRUE"
|
||||
|
||||
# Google OAuth
|
||||
|
|
@ -916,7 +916,7 @@ class Config:
|
|||
|
||||
# JWT Token Lifetimes
|
||||
ACCESS_TOKEN_LIFETIME_SECONDS = int(
|
||||
os.getenv("ACCESS_TOKEN_LIFETIME_SECONDS", str(30 * 60)) # 30 minutes
|
||||
os.getenv("ACCESS_TOKEN_LIFETIME_SECONDS", str(60 * 60)) # 60 minutes
|
||||
)
|
||||
MIN_ISSUED_AT = int(os.getenv("MIN_ISSUED_AT", "0"))
|
||||
REFRESH_TOKEN_LIFETIME_SECONDS = int(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from app.utils.document_converters import (
|
|||
create_document_chunks,
|
||||
embed_text,
|
||||
generate_content_hash,
|
||||
truncate_for_embedding,
|
||||
)
|
||||
|
||||
from ._helpers import (
|
||||
|
|
@ -73,7 +74,9 @@ async def save_file_document(
|
|||
if should_skip:
|
||||
return doc
|
||||
|
||||
document_content = f"File: {file_name}\n\n{markdown_content[:4000]}"
|
||||
document_content = (
|
||||
f"File: {file_name}\n\n{truncate_for_embedding(markdown_content)}"
|
||||
)
|
||||
document_embedding = embed_text(document_content)
|
||||
chunks = await create_document_chunks(markdown_content)
|
||||
doc_metadata = {"FILE_NAME": file_name, "ETL_SERVICE": etl_service}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from app.utils.document_converters import (
|
|||
create_document_chunks,
|
||||
embed_text,
|
||||
generate_content_hash,
|
||||
truncate_for_embedding,
|
||||
)
|
||||
|
||||
from ._helpers import (
|
||||
|
|
@ -182,7 +183,9 @@ async def add_received_markdown_file_document(
|
|||
return doc
|
||||
# Content changed - continue to update
|
||||
|
||||
summary_content = f"File: {file_name}\n\n{file_in_markdown[:4000]}"
|
||||
summary_content = (
|
||||
f"File: {file_name}\n\n{truncate_for_embedding(file_in_markdown)}"
|
||||
)
|
||||
summary_embedding = embed_text(summary_content)
|
||||
|
||||
# Process chunks
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ def _render_block(
|
|||
code_text = _render_inline_content(content) if content else ""
|
||||
lines.append(f"{prefix}```{language}")
|
||||
for code_line in code_text.split("\n"):
|
||||
lines.append(f"{prefix}{code_line}")
|
||||
lines.append(code_line)
|
||||
lines.append(f"{prefix}```")
|
||||
|
||||
elif block_type == "table":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue