feat: auto activity logging on issue create/delete, fix schema db.add bug

This commit is contained in:
Zhi
2026-02-27 09:39:39 +00:00
parent a56faacc4c
commit 3cf2b1bc49
3 changed files with 23 additions and 1 deletions

18
app/services/activity.py Normal file
View File

@@ -0,0 +1,18 @@
"""Activity logging helper — auto-record CRUD operations."""
import json
from sqlalchemy.orm import Session
from app.models.activity import ActivityLog
def log_activity(db: Session, action: str, entity_type: str, entity_id: int, user_id: int = None, details: dict = None):
"""Record an activity log entry."""
entry = ActivityLog(
action=action,
entity_type=entity_type,
entity_id=entity_id,
user_id=user_id,
details=json.dumps(details) if details else None,
)
db.add(entry)
db.commit()
return entry