From d3d31c21114c1eecddcfbb456764dcb9b2725739 Mon Sep 17 00:00:00 2001 From: majun <3060162534@qq.com> Date: Tue, 24 Dec 2024 10:36:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E4=BC=98=E5=8C=96=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=AC=A1=E6=95=B0=E6=9F=A5=E8=AF=A2=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- link_homework/internal/logic/homework/homework.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/link_homework/internal/logic/homework/homework.go b/link_homework/internal/logic/homework/homework.go index eb600dc..6f3594e 100644 --- a/link_homework/internal/logic/homework/homework.go +++ b/link_homework/internal/logic/homework/homework.go @@ -78,9 +78,8 @@ func UpdateHomework(ctx context.Context, homeworkList []*entity.ActivityInteract v.Status = 1 } if v.Status != 0 { - rCount, _ := dao.ActivityInteractiveRecord.Ctx(ctx).Where("group_id", v.Id).Count() - tCount, _ := dao.ActivityInteractiveForm.Ctx(ctx).Where("group_id", v.Id).Count() - v.Count = rCount / tCount + result, _ := dao.ActivityInteractiveRecord.Ctx(ctx).Where("group_id", v.Id).Group("form_id").Limit(1).Value("COUNT(*)") + v.Count = result.Int() } } } @@ -91,9 +90,10 @@ func UpdateHomework(ctx context.Context, homeworkList []*entity.ActivityInteract func InitHomework(ctx context.Context, homeworkList []*entity.ActivityInteractiveGroup) []*entity.ActivityInteractiveGroup { for _, v := range homeworkList { if v.Status == 2 { - rCount, _ := dao.ActivityInteractiveRecord.Ctx(ctx).Where("group_id", v.Id).Count() - tCount, _ := dao.ActivityInteractiveForm.Ctx(ctx).Where("group_id", v.Id).Count() - v.Count = rCount / tCount + if v.Status != 0 { + result, _ := dao.ActivityInteractiveRecord.Ctx(ctx).Where("group_id", v.Id).Group("form_id").Limit(1).Value("COUNT(*)") + v.Count = result.Int() + } } }