fix: resolve bugs 01 through 08 and set Ollama TTL to 1h
This commit is contained in:
@@ -38,11 +38,15 @@ async def api_lookup(
|
||||
raise HTTPException(status_code=400, detail="Query term cannot be empty")
|
||||
data = await lookup_term(query_str)
|
||||
|
||||
# Ensure term is always present in response
|
||||
target_term = data.get("term") or data.get("english_term") or query_str
|
||||
data["term"] = target_term
|
||||
|
||||
# Check if this term already exists in user's dictionary
|
||||
with get_db() as conn:
|
||||
existing = conn.execute(
|
||||
"SELECT id, term, translation, context_sentence, tags, collection, srs_state, srs_reps FROM vocabulary_cards WHERE user_id = ? AND lower(trim(term)) = lower(trim(?))",
|
||||
(user["id"], query_str),
|
||||
"SELECT id, term, translation, context_sentence, tags, collection, srs_state, srs_reps FROM vocabulary_cards WHERE user_id = ? AND (lower(trim(term)) = lower(trim(?)) OR lower(trim(term)) = lower(trim(?)))",
|
||||
(user["id"], target_term, query_str),
|
||||
).fetchone()
|
||||
if existing:
|
||||
data["in_library"] = True
|
||||
|
||||
Reference in New Issue
Block a user