From 17326a16a018ae84d274be53b52be9273ef69932 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Mon, 1 Jul 2024 18:44:41 -0400 Subject: Update local.yaml to set is_done_tick_dot_com to false, add things history --- internal/thing/handler.go | 3 ++- internal/thing/repo/repository.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'internal/thing') diff --git a/internal/thing/handler.go b/internal/thing/handler.go index 5166157..65bc871 100644 --- a/internal/thing/handler.go +++ b/internal/thing/handler.go @@ -227,7 +227,8 @@ func (h *Handler) GetThingHistory(c *gin.Context) { c.JSON(400, gin.H{"error": "Invalid offset"}) return } - history, err := h.tRepo.GetThingHistoryWithOffset(c, thingID, offset, 10) + + history, err := h.tRepo.GetThingHistoryWithOffset(c, thingID, offset) if err != nil { c.JSON(500, gin.H{"error": err.Error()}) return diff --git a/internal/thing/repo/repository.go b/internal/thing/repo/repository.go index 8b2dbaa..a7b1fc9 100644 --- a/internal/thing/repo/repository.go +++ b/internal/thing/repo/repository.go @@ -70,9 +70,9 @@ func (r *ThingRepository) DissociateThingWithChore(c context.Context, thingID in return r.db.WithContext(c).Where("thing_id = ? AND chore_id = ?", thingID, choreID).Delete(&tModel.ThingChore{}).Error } -func (r *ThingRepository) GetThingHistoryWithOffset(c context.Context, thingID int, offset int, limit int) ([]*tModel.ThingHistory, error) { +func (r *ThingRepository) GetThingHistoryWithOffset(c context.Context, thingID int, offset int) ([]*tModel.ThingHistory, error) { var thingHistory []*tModel.ThingHistory - if err := r.db.WithContext(c).Model(&tModel.ThingHistory{}).Where("thing_id = ?", thingID).Order("created_at desc").Offset(offset).Limit(limit).Find(&thingHistory).Error; err != nil { + if err := r.db.WithContext(c).Model(&tModel.ThingHistory{}).Where("thing_id = ?", thingID).Order("created_at desc").Offset(offset).Limit(10).Find(&thingHistory).Error; err != nil { return nil, err } return thingHistory, nil -- cgit