feat: add admin dashboard, pipeline service, lightbox, and update dependencies

This commit is contained in:
2026-06-09 09:32:10 +08:00
parent 0d293422ac
commit 32978b3fc5
50 changed files with 4054 additions and 1618 deletions
+16 -28
View File
@@ -6,11 +6,11 @@ import logging
import math
import re
from sqlalchemy import text
from sqlalchemy.orm import Session, joinedload
from sqlalchemy import select, text
from sqlalchemy.orm import Session
from app.config import settings
from app.models import Paper
from app.models import PAPER_FULL_LOAD, Paper
logger = logging.getLogger(__name__)
@@ -213,21 +213,15 @@ def _search_semantic(
arxiv_ids = [c["arxiv_id"] for c in candidates]
distance_map = {c["arxiv_id"]: c["distance"] for c in candidates}
papers_query = (
db.query(Paper)
.filter(Paper.arxiv_id.in_(arxiv_ids))
.options(
joinedload(Paper.authors),
joinedload(Paper.tags),
joinedload(Paper.summary_status),
joinedload(Paper.bookmark),
joinedload(Paper.reading_status),
)
stmt = (
select(Paper)
.where(Paper.arxiv_id.in_(arxiv_ids))
.options(*PAPER_FULL_LOAD)
)
if tag:
papers_query = papers_query.filter(Paper.tags.any(tag=tag))
stmt = stmt.where(Paper.tags.any(tag=tag))
papers = papers_query.all()
papers = db.execute(stmt).unique().scalars().all()
# 按语义距离排序
id_order = {aid: idx for idx, aid in enumerate(arxiv_ids)}
@@ -257,11 +251,7 @@ def _search_tag_only(
offset: int,
) -> dict:
"""只有标签筛选,无关键词。"""
order = (
"p.paper_date DESC, p.upvotes DESC"
if sort == "date"
else "p.paper_date DESC, p.upvotes DESC"
)
order = "p.paper_date DESC, p.upvotes DESC"
rows_sql = text(f"""
SELECT p.id
@@ -307,15 +297,13 @@ def _load_papers_by_ids(
return []
papers = (
db.query(Paper)
.filter(Paper.id.in_(paper_ids))
.options(
joinedload(Paper.authors),
joinedload(Paper.tags),
joinedload(Paper.summary_status),
joinedload(Paper.bookmark),
joinedload(Paper.reading_status),
db.execute(
select(Paper)
.where(Paper.id.in_(paper_ids))
.options(*PAPER_FULL_LOAD)
)
.unique()
.scalars()
.all()
)