Implement optimized label feature with batched queries#13
Draft
Implement optimized label feature with batched queries#13
Conversation
Co-authored-by: kavyashri-as <213833080+kavyashri-as@users.noreply.github.com> Agent-Logs-Url: https://github.com/CanarysPlayground/TaskManagerApp/sessions/71467eb8-138d-48cf-9a84-f15c39c98549
Co-authored-by: kavyashri-as <213833080+kavyashri-as@users.noreply.github.com> Agent-Logs-Url: https://github.com/CanarysPlayground/TaskManagerApp/sessions/71467eb8-138d-48cf-9a84-f15c39c98549
…ignment Co-authored-by: kavyashri-as <213833080+kavyashri-as@users.noreply.github.com> Agent-Logs-Url: https://github.com/CanarysPlayground/TaskManagerApp/sessions/71467eb8-138d-48cf-9a84-f15c39c98549
Copilot
AI
changed the title
[WIP] Optimize label feature in Task Manager app
Implement optimized label feature with batched queries
Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds label functionality with N+1 query optimization built in. Previously would require N+1 queries (one per task) to fetch labels; now uses single JOIN query to fetch labels for all tasks.
Database Schema
labelstable:id,name(unique),color,created_attask_labelsjunction table: composite PK on(task_id, label_id), foreign keys with CASCADEtask_idandlabel_idfor JOIN performanceCore Optimization
getTaskLabelsOptimized()batches label fetching:enrichTasksWithLabels()helper applies this pattern to/api/tasksand/routes, reducing queries from N+1 to 2 total (1 for tasks, 1 for all labels).API Endpoints
POST /api/labels- create label (validates hex color, enforces unique names)GET /api/labels- list all labelsPOST /api/tasks/:id/labels- assign label(s), supports{labelId: 1}or{labelIds: [1,2,3]}DELETE /api/tasks/:id/labels/:labelId- remove labelPOST /api/tasks/bulk/labels- bulk assign via{assignments: [{taskId, labelId}, ...]}GET /api/tasks- now includeslabelsarray per taskImplementation Notes
callbackCalledflag to prevent race condition in async forEach loops/api/tasks/bulk/labelsplaced before/api/tasks/:id/*to avoid param matchingOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.