Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions backend/routers/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ async def create_issue(
hash_content = f"{description}|{category}|{prev_hash}"
integrity_hash = hashlib.sha256(hash_content.encode()).hexdigest()

# Update cache for next report
blockchain_last_hash_cache.set(data=integrity_hash, key="last_hash")

# RAG Retrieval (New)
relevant_rule = rag_service.retrieve(description)
initial_action_plan = None
Expand All @@ -212,10 +209,16 @@ async def create_issue(

# Offload blocking DB operations to threadpool
await run_in_threadpool(save_issue_db, db, new_issue)

# Update cache only after a successful DB commit
blockchain_last_hash_cache.set(data=integrity_hash, key="last_hash")
else:
# Don't create new issue, just return deduplication info
new_issue = None
except Exception as e:
# Invalidate cache so next request re-fetches the true last hash from DB
blockchain_last_hash_cache.invalidate("last_hash")

# Clean up uploaded file if DB save failed
if image_path and os.path.exists(image_path):
try:
Expand Down