This commit is contained in:
@@ -27,10 +27,13 @@ func CreateCounterHandler(c *gin.Context) {
|
||||
).Scan(&counter.ID, &counter.UserID, &counter.Name, &counter.Description, &counter.CreatedAt, &counter.UpdatedAt)
|
||||
|
||||
if err != nil {
|
||||
RecordDBOperation("insert", "counters")
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to create counter"})
|
||||
return
|
||||
}
|
||||
|
||||
RecordDBOperation("insert", "counters")
|
||||
|
||||
c.JSON(http.StatusCreated, counter)
|
||||
}
|
||||
|
||||
@@ -61,11 +64,14 @@ func GetCountersHandler(c *gin.Context) {
|
||||
|
||||
rows, err := db.Query(query, args...)
|
||||
if err != nil {
|
||||
RecordDBOperation("select", "counters")
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch counters"})
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
RecordDBOperation("select", "counters")
|
||||
|
||||
counters := []CounterWithStats{} // Initialize as empty slice, not nil
|
||||
for rows.Next() {
|
||||
var counter CounterWithStats
|
||||
|
||||
Reference in New Issue
Block a user