sync snapshot from LAN repo (source codex/merge-tjlnew-classic-retrieval-20261019 @ ded012d9)
This commit is contained in:
1 parent
ea9dcff9c0
commit
c753e6c9b5
818 files changed
+14037
-108991
No files matched your search
@@ -9,7 +9,6 @@ from uuid import uuid4
|
||||
from fastapi import APIRouter, HTTPException, Query, Request
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.gateway.api_read_cache import get_cache_version, get_cached_json, set_cached_json
|
||||
from deerflow.runtime.user_context import get_effective_user_id
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -66,16 +65,6 @@ async def list_recommended_questions(
|
||||
all: bool = Query(default=False, description="Admin management view: return every question, unfiltered by 岗位."),
|
||||
tag_ids: list[str] | None = Query(default=None, description="Keep questions carrying any of these tags (OR)."),
|
||||
) -> RecommendedQuestionsListResponse:
|
||||
user_id = _current_user_id(request)
|
||||
config = getattr(request.app.state, "config", None)
|
||||
cache_key = f"user:{user_id}"
|
||||
normalized_tag_ids = tag_ids if isinstance(tag_ids, list) else None
|
||||
cacheable = not all and not normalized_tag_ids
|
||||
version = await get_cache_version(config, "recommended_questions") if cacheable else None
|
||||
if cacheable:
|
||||
cached = await get_cached_json(config, "recommended_questions", cache_key, version=version)
|
||||
if cached is not None:
|
||||
return RecommendedQuestionsListResponse.model_validate(cached)
|
||||
store = _get_store(request)
|
||||
rows = await store.list_all()
|
||||
responses = [RecommendedQuestionResponse(**r) for r in rows]
|
||||
@@ -102,7 +91,7 @@ async def list_recommended_questions(
|
||||
sync = getattr(request.app.state, "position_sync", None)
|
||||
if sync is not None:
|
||||
try:
|
||||
visible = await sync.resolve_visible(user_id, "recommended_question")
|
||||
visible = await sync.resolve_visible(_current_user_id(request), "recommended_question")
|
||||
except Exception:
|
||||
logger.debug("recommended-question visibility resolve failed", exc_info=True)
|
||||
visible = None
|
||||
@@ -111,20 +100,11 @@ async def list_recommended_questions(
|
||||
else:
|
||||
responses = [r for r in responses if not r.tags]
|
||||
|
||||
if normalized_tag_ids:
|
||||
wanted = set(normalized_tag_ids)
|
||||
if tag_ids:
|
||||
wanted = set(tag_ids)
|
||||
responses = [r for r in responses if any(t.get("id") in wanted for t in r.tags)]
|
||||
|
||||
result = RecommendedQuestionsListResponse(questions=responses)
|
||||
if cacheable:
|
||||
await set_cached_json(
|
||||
config,
|
||||
"recommended_questions",
|
||||
cache_key,
|
||||
result,
|
||||
expected_version=version,
|
||||
)
|
||||
return result
|
||||
return RecommendedQuestionsListResponse(questions=responses)
|
||||
|
||||
|
||||
@router.post("/recommended-questions", response_model=RecommendedQuestionResponse, status_code=201)
|
||||
|
||||
Reference in new issue
Block a user