Remove summary from list API responses
Summary statistics are now calculated client-side from kanban data. This removes the summary field from MyResidencesResponse and KanbanBoardResponse. Mutation endpoints still return summary via WithSummaryResponse<T> for immediate cache updates. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -64,9 +64,9 @@ type TotalSummary struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MyResidencesResponse represents the response for my-residences endpoint
|
// MyResidencesResponse represents the response for my-residences endpoint
|
||||||
|
// NOTE: Summary statistics are calculated client-side from kanban data
|
||||||
type MyResidencesResponse struct {
|
type MyResidencesResponse struct {
|
||||||
Residences []ResidenceResponse `json:"residences"`
|
Residences []ResidenceResponse `json:"residences"`
|
||||||
Summary TotalSummary `json:"summary"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResidenceWithSummaryResponse wraps ResidenceResponse with TotalSummary for CRUD operations
|
// ResidenceWithSummaryResponse wraps ResidenceResponse with TotalSummary for CRUD operations
|
||||||
|
|||||||
@@ -114,11 +114,11 @@ type KanbanColumnResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// KanbanBoardResponse represents the kanban board
|
// KanbanBoardResponse represents the kanban board
|
||||||
|
// NOTE: Summary statistics are calculated client-side from kanban data
|
||||||
type KanbanBoardResponse struct {
|
type KanbanBoardResponse struct {
|
||||||
Columns []KanbanColumnResponse `json:"columns"`
|
Columns []KanbanColumnResponse `json:"columns"`
|
||||||
DaysThreshold int `json:"days_threshold"`
|
DaysThreshold int `json:"days_threshold"`
|
||||||
ResidenceID string `json:"residence_id"`
|
ResidenceID string `json:"residence_id"`
|
||||||
Summary *TotalSummary `json:"summary,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: TaskCompletionListResponse pagination removed - returns arrays directly
|
// Note: TaskCompletionListResponse pagination removed - returns arrays directly
|
||||||
|
|||||||
@@ -88,9 +88,8 @@ func (s *ResidenceService) ListResidences(userID uint) ([]responses.ResidenceRes
|
|||||||
// This is the "my-residences" endpoint that returns richer data.
|
// This is the "my-residences" endpoint that returns richer data.
|
||||||
// The `now` parameter should be the start of day in the user's timezone for accurate overdue detection.
|
// The `now` parameter should be the start of day in the user's timezone for accurate overdue detection.
|
||||||
//
|
//
|
||||||
// NOTE: Summary statistics (TotalTasks, TotalOverdue, etc.) are now calculated client-side
|
// NOTE: Summary statistics (TotalTasks, TotalOverdue, etc.) are calculated client-side
|
||||||
// from kanban data for performance. Only TotalResidences and per-residence OverdueCount
|
// from kanban data for performance. Only per-residence OverdueCount is returned from the server.
|
||||||
// are returned from the server.
|
|
||||||
func (s *ResidenceService) GetMyResidences(userID uint, now time.Time) (*responses.MyResidencesResponse, error) {
|
func (s *ResidenceService) GetMyResidences(userID uint, now time.Time) (*responses.MyResidencesResponse, error) {
|
||||||
residences, err := s.residenceRepo.FindByUser(userID)
|
residences, err := s.residenceRepo.FindByUser(userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -99,12 +98,6 @@ func (s *ResidenceService) GetMyResidences(userID uint, now time.Time) (*respons
|
|||||||
|
|
||||||
residenceResponses := responses.NewResidenceListResponse(residences)
|
residenceResponses := responses.NewResidenceListResponse(residences)
|
||||||
|
|
||||||
// Summary statistics (TotalTasks, TotalOverdue, etc.) are calculated client-side
|
|
||||||
// from kanban data. We only populate TotalResidences here.
|
|
||||||
summary := responses.TotalSummary{
|
|
||||||
TotalResidences: len(residences),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get per-residence overdue counts for residence card badges
|
// Get per-residence overdue counts for residence card badges
|
||||||
if s.taskRepo != nil && len(residences) > 0 {
|
if s.taskRepo != nil && len(residences) > 0 {
|
||||||
residenceIDs := make([]uint, len(residences))
|
residenceIDs := make([]uint, len(residences))
|
||||||
@@ -124,7 +117,6 @@ func (s *ResidenceService) GetMyResidences(userID uint, now time.Time) (*respons
|
|||||||
|
|
||||||
return &responses.MyResidencesResponse{
|
return &responses.MyResidencesResponse{
|
||||||
Residences: residenceResponses,
|
Residences: residenceResponses,
|
||||||
Summary: summary,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,9 +116,7 @@ func (s *TaskService) ListTasks(userID uint, now time.Time) (*responses.KanbanBo
|
|||||||
}
|
}
|
||||||
|
|
||||||
resp := responses.NewKanbanBoardResponseForAll(board)
|
resp := responses.NewKanbanBoardResponseForAll(board)
|
||||||
// Include summary for dashboard stats
|
// NOTE: Summary statistics are calculated client-side from kanban data
|
||||||
summary := s.getSummaryForUser(userID)
|
|
||||||
resp.Summary = &summary
|
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,9 +143,7 @@ func (s *TaskService) GetTasksByResidence(residenceID, userID uint, daysThreshol
|
|||||||
}
|
}
|
||||||
|
|
||||||
resp := responses.NewKanbanBoardResponse(board, residenceID)
|
resp := responses.NewKanbanBoardResponse(board, residenceID)
|
||||||
// Include summary for dashboard stats
|
// NOTE: Summary statistics are calculated client-side from kanban data
|
||||||
summary := s.getSummaryForUser(userID)
|
|
||||||
resp.Summary = &summary
|
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user