aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/chore/repo/repository.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/chore/repo/repository.go b/internal/chore/repo/repository.go
index 51ebb2c..4eac59c 100644
--- a/internal/chore/repo/repository.go
+++ b/internal/chore/repo/repository.go
@@ -111,6 +111,13 @@ func (r *ChoreRepository) GetChoreHistory(c context.Context, choreID int) ([]*ch
}
return histories, nil
}
+func (r *ChoreRepository) GetChoreHistoryWithLimit(c context.Context, choreID int, limit int) ([]*chModel.ChoreHistory, error) {
+ var histories []*chModel.ChoreHistory
+ if err := r.db.WithContext(c).Where("chore_id = ?", choreID).Order("completed_at desc").Limit(limit).Find(&histories).Error; err != nil {
+ return nil, err
+ }
+ return histories, nil
+}
func (r *ChoreRepository) UpdateChoreAssignees(c context.Context, assignees []*chModel.ChoreAssignees) error {
return r.db.WithContext(c).Save(&assignees).Error
@@ -243,7 +250,7 @@ func (r *ChoreRepository) GetChoreDetailByID(c context.Context, choreID int, cir
)
) AS recent_history ON chores.id = recent_history.chore_id`).
Where("chores.id = ? and chores.circle_id = ?", choreID, circleID).
- Group("chores.id, recent_history.last_completed_date").
+ Group("chores.id, recent_history.last_completed_date, recent_history.last_assigned_to").
First(&choreDetail).Error; err != nil {
return nil, err