aboutsummaryrefslogtreecommitdiffstats
path: root/internal/chore/repo
diff options
context:
space:
mode:
authorLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-07 00:26:08 -0400
committerLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-07 00:26:08 -0400
commit010db330a46ad32daf30400283971cd4e9835e1d (patch)
tree83d169e5a73345e8ce2492568366432997a1199b /internal/chore/repo
parentc92cdb427d050456769f520cdcc4ee10db895ad9 (diff)
downloaddonetick-010db330a46ad32daf30400283971cd4e9835e1d.tar.gz
donetick-010db330a46ad32daf30400283971cd4e9835e1d.tar.bz2
donetick-010db330a46ad32daf30400283971cd4e9835e1d.zip
chore: Update chore detail query to include notes in result
Diffstat (limited to '')
-rw-r--r--internal/chore/repo/repository.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/internal/chore/repo/repository.go b/internal/chore/repo/repository.go
index 4eac59c..7284202 100644
--- a/internal/chore/repo/repository.go
+++ b/internal/chore/repo/repository.go
@@ -234,6 +234,7 @@ func (r *ChoreRepository) GetChoreDetailByID(c context.Context, choreID int, cir
chores.assigned_to,
chores.created_by,
recent_history.last_completed_date,
+ recent_history.notes,
recent_history.last_assigned_to as last_completed_by,
COUNT(chore_histories.id) as total_completed`).
Joins("LEFT JOIN chore_histories ON chores.id = chore_histories.chore_id").
@@ -241,7 +242,9 @@ func (r *ChoreRepository) GetChoreDetailByID(c context.Context, choreID int, cir
SELECT
chore_id,
assigned_to AS last_assigned_to,
- completed_at AS last_completed_date
+ completed_at AS last_completed_date,
+ notes
+
FROM chore_histories
WHERE (chore_id, completed_at) IN (
SELECT chore_id, MAX(completed_at)
@@ -250,7 +253,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, recent_history.last_assigned_to").
+ Group("chores.id, recent_history.last_completed_date, recent_history.last_assigned_to, recent_history.notes").
First(&choreDetail).Error; err != nil {
return nil, err