mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 14:55:42 +00:00
add api upload documents daily checklist
This commit is contained in:
@@ -63,6 +63,40 @@ func (s phasesService) GetAll(c *fiber.Ctx, params *validation.Query) ([]entity.
|
||||
s.Log.Errorf("Failed to get phasess: %+v", err)
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
if len(phasess) > 0 {
|
||||
ids := make([]uint, 0, len(phasess))
|
||||
for _, phase := range phasess {
|
||||
ids = append(ids, phase.Id)
|
||||
}
|
||||
|
||||
type activityCountRow struct {
|
||||
PhaseID uint
|
||||
Count int64
|
||||
}
|
||||
|
||||
var rows []activityCountRow
|
||||
if err := s.Repository.DB().WithContext(c.Context()).
|
||||
Table("phase_activities").
|
||||
Select("phase_id, COUNT(*) AS count").
|
||||
Where("phase_id IN ? AND deleted_at IS NULL", ids).
|
||||
Group("phase_id").
|
||||
Scan(&rows).Error; err != nil {
|
||||
s.Log.Errorf("Failed to count phase activities: %+v", err)
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
countMap := make(map[uint]int64, len(rows))
|
||||
for _, row := range rows {
|
||||
countMap[row.PhaseID] = row.Count
|
||||
}
|
||||
|
||||
for i := range phasess {
|
||||
if count, ok := countMap[phasess[i].Id]; ok {
|
||||
phasess[i].ActivityCount = int(count)
|
||||
}
|
||||
}
|
||||
}
|
||||
return phasess, total, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user