Add performance optimizations and database indexes
Database Indexes (migrations 006-009): - Add case-insensitive indexes for auth lookups (email, username) - Add composite indexes for task kanban queries - Add indexes for notification, document, and completion queries - Add unique index for active share codes - Remove redundant idx_share_code_active and idx_notification_user_sent Repository Optimizations: - Add FindResidenceIDsByUser() lightweight method (IDs only, no preloads) - Optimize GetResidenceUsers() with single UNION query (was 2 queries) - Optimize kanban completion preloads to minimal columns (id, task_id, completed_at) Service Optimizations: - Remove Category/Priority/Frequency preloads from task queries - Remove summary calculations from CRUD responses (client calculates) - Use lightweight FindResidenceIDsByUser() instead of full FindByUser() These changes reduce database load and response times for common operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -76,8 +76,10 @@ func TestTaskService_CreateTask_WithOptionalFields(t *testing.T) {
|
||||
|
||||
resp, err := service.CreateTask(req, user.ID)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp.Data.Category)
|
||||
assert.NotNil(t, resp.Data.Priority)
|
||||
// Note: Category and Priority are no longer preloaded for performance
|
||||
// Client resolves from cache using CategoryID and PriorityID
|
||||
assert.NotNil(t, resp.Data.CategoryID, "CategoryID should be set")
|
||||
assert.NotNil(t, resp.Data.PriorityID, "PriorityID should be set")
|
||||
assert.NotNil(t, resp.Data.DueDate)
|
||||
assert.NotNil(t, resp.Data.EstimatedCost)
|
||||
}
|
||||
@@ -149,7 +151,7 @@ func TestTaskService_ListTasks(t *testing.T) {
|
||||
testutil.CreateTestTask(t, db, residence.ID, user.ID, "Task 2")
|
||||
testutil.CreateTestTask(t, db, residence.ID, user.ID, "Task 3")
|
||||
|
||||
resp, err := service.ListTasks(user.ID)
|
||||
resp, err := service.ListTasks(user.ID, time.Now().UTC())
|
||||
require.NoError(t, err)
|
||||
// ListTasks returns a KanbanBoardResponse with columns
|
||||
// Count total tasks across all columns
|
||||
|
||||
Reference in New Issue
Block a user