refactor: make database name configurable in admin routes and bug report deletion
Some checks failed
Build & Publish Docker Image / build-and-push (push) Failing after 9s

This commit is contained in:
Flavio Fois
2026-05-27 23:21:20 +02:00
parent 3347f9ba4e
commit bca15fe636
3 changed files with 20 additions and 3 deletions

View File

@@ -544,21 +544,28 @@ func DeleteBugReportByID(db *sqlx.DB, dbName string) http.HandlerFunc {
return
}
log.Printf("[BUGREPORT] Delete requested: report_id=%s", reportId)
result, err := db.ExecContext(r.Context(), fmt.Sprintf("DELETE FROM %s.bug_reports WHERE id = ?", dbName), reportId)
if err != nil {
log.Printf("[BUGREPORT] Delete failed: report_id=%s err=%v", reportId, err)
jsonError(w, http.StatusInternalServerError, err.Error())
return
}
rowsAffected, err := result.RowsAffected()
if err != nil {
log.Printf("[BUGREPORT] Delete rows check failed: report_id=%s err=%v", reportId, err)
jsonError(w, http.StatusInternalServerError, err.Error())
return
}
if rowsAffected == 0 {
log.Printf("[BUGREPORT] Delete skipped: report_id=%s not found", reportId)
jsonError(w, http.StatusNotFound, "bug report not found")
return
}
log.Printf("[BUGREPORT] Deleted successfully: report_id=%s rows=%d", reportId, rowsAffected)
jsonOK(w, map[string]string{"message": "bug report deleted successfully"})
}
}