Skip to content

Commit 9fb78d9

Browse files
committed
fix: Implement filterType parameter parsing in workspace devlogs API
1 parent 1696e27 commit 9fb78d9

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"id": 272,
3+
"key": "fix-filtertype-parameter-not-working-in-workspace-",
4+
"title": "Fix filterType parameter not working in workspace devlogs API",
5+
"type": "bugfix",
6+
"description": "The filterType=open query parameter in the /api/workspaces/default/devlogs API endpoint is not being parsed or applied, causing the filter to be ignored. Users cannot filter devlogs by 'open', 'closed', or other FilterType values.",
7+
"status": "done",
8+
"priority": "high",
9+
"createdAt": "2025-07-24T12:48:37.552Z",
10+
"updatedAt": "2025-07-24T12:51:10.830Z",
11+
"notes": [
12+
{
13+
"id": "ff9c006a-9eae-4eef-955d-24461dcdc6db",
14+
"timestamp": "2025-07-24T12:49:27.720Z",
15+
"category": "solution",
16+
"content": "✅ **ROOT CAUSE IDENTIFIED**: The API route was not parsing the `filterType` query parameter.\n\n**SOLUTION IMPLEMENTED**: \n1. Added import for `filterTypeToStatusFilter` and `FilterType` from `@devlog/core`\n2. Added parsing logic for `filterType` parameter that converts it to appropriate status array using the utility function\n3. Logic properly handles precedence: `filterType` sets initial status array, but individual `status` parameter can override it\n\n**KEY CHANGES**:\n- `filterType=open` → converts to `status: ['new', 'in-progress', 'blocked', 'in-review', 'testing']`\n- `filterType=closed` → converts to `status: ['done', 'cancelled']` \n- `filterType=total` → no status filtering applied\n- Individual status values like `filterType=new` → converts to `status: ['new']`\n\nThe fix maintains backward compatibility and follows the existing filtering architecture.",
17+
"files": [
18+
"packages/web/app/api/workspaces/[id]/devlogs/route.ts"
19+
]
20+
},
21+
{
22+
"id": "4fac432b-ccf9-4f54-9fcf-c1340395fcef",
23+
"timestamp": "2025-07-24T12:50:42.293Z",
24+
"category": "progress",
25+
"content": "✅ **COMPREHENSIVE TESTING COMPLETED** - All acceptance criteria validated!\n\n**Test Results:**\n\n1. **✅ filterType=open works correctly**:\n - Returns devlogs with statuses: `new`, `in-progress`, `blocked`, `in-review`, `testing`\n - Test confirmed returned entries had `\"status\":\"in-progress\"` and `\"status\":\"new\"`\n\n2. **✅ filterType=closed works correctly**:\n - Returns devlogs with statuses: `done`, `cancelled`\n - Test confirmed all returned entries had `\"status\":\"done\"`\n\n3. **✅ filterType=total works correctly**:\n - Returns all devlogs regardless of status\n - Test confirmed mixed statuses: `\"status\":\"done\"` and `\"status\":\"in-progress\"`\n\n4. **✅ Individual status filterType works**:\n - `filterType=new` correctly returned only `\"status\":\"new\"` entries\n\n5. **✅ Backward compatibility maintained**:\n - Original `status=done` parameter still works correctly\n\n6. **✅ Precedence rules work correctly**:\n - `filterType=open&status=done` correctly prioritized `status` parameter\n - Returned `\"status\":\"done\"` entries (not open statuses)\n\n7. **✅ Combined filtering works**:\n - `filterType=open&type=bugfix` correctly filtered by both criteria\n - Returned entries with open status AND bugfix type\n\n**API Endpoint Verified**: `http://localhost:3200/api/workspaces/default/devlogs?filterType=open`"
26+
},
27+
{
28+
"id": "9c6e6248-788a-4162-b3c7-4bda49f72517",
29+
"timestamp": "2025-07-24T12:51:10.829Z",
30+
"category": "progress",
31+
"content": "Completed: ✅ **SUCCESSFULLY FIXED** filterType parameter not working in workspace devlogs API.\n\n**Problem**: The `/api/workspaces/default/devlogs` endpoint was ignoring the `filterType=open` query parameter because the API route wasn't parsing it.\n\n**Solution**: \n- Added import for `filterTypeToStatusFilter` and `FilterType` from `@devlog/core`\n- Added parsing logic that converts `filterType` to appropriate status array\n- Implemented proper precedence: filterType sets initial filter, individual status parameter can override\n\n**Validation**: All acceptance criteria tested and confirmed working:\n- ✅ filterType=open returns only open statuses\n- ✅ filterType=closed returns only closed statuses \n- ✅ filterType=total returns all devlogs\n- ✅ Individual status values work correctly\n- ✅ Backward compatibility maintained\n- ✅ Precedence rules work correctly\n- ✅ Combined with other filters works\n\nThe fix follows existing filtering architecture patterns and maintains full backward compatibility."
32+
}
33+
],
34+
"files": [],
35+
"relatedDevlogs": [],
36+
"context": {
37+
"businessContext": "Users need to be able to filter devlog lists by categories like 'open' (showing active work) and 'closed' (showing completed work) for better task management and visibility into work status.",
38+
"technicalContext": "The DevlogFilter interface includes a filterType property that accepts FilterType values ('open', 'closed', 'total', or individual statuses), but the API route is not parsing the filterType query parameter from the request and adding it to the filter object passed to listDevlogsFromWorkspace.",
39+
"dependencies": [],
40+
"decisions": [],
41+
"acceptanceCriteria": [
42+
"API parses filterType query parameter correctly",
43+
"filterType=open returns only devlogs with open statuses (new, in-progress, blocked, in-review, testing)",
44+
"filterType=closed returns only devlogs with closed statuses (done, cancelled)",
45+
"filterType=total returns all devlogs regardless of status",
46+
"Individual status filterType values work correctly",
47+
"Existing filtering (status, type, priority, archived) continues to work",
48+
"API maintains backward compatibility"
49+
],
50+
"risks": []
51+
},
52+
"aiContext": {
53+
"currentSummary": "",
54+
"keyInsights": [],
55+
"openQuestions": [],
56+
"relatedPatterns": [],
57+
"suggestedNextSteps": [],
58+
"lastAIUpdate": "2025-07-24T12:48:37.552Z",
59+
"contextVersion": 1
60+
},
61+
"closedAt": "2025-07-24T12:51:10.830Z"
62+
}

packages/web/app/api/workspaces/[id]/devlogs/route.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { NextRequest, NextResponse } from 'next/server';
22
import { getSharedWorkspaceManager } from '@/lib/shared-workspace-manager';
3+
import { filterTypeToStatusFilter, type FilterType } from '@devlog/core';
34

45
// Mark this route as dynamic to prevent static generation
56
export const dynamic = 'force-dynamic';
@@ -12,7 +13,18 @@ export async function GET(request: NextRequest, { params }: { params: { id: stri
1213
const { searchParams } = new URL(request.url);
1314
const filter: any = {};
1415

15-
// Parse query parameters (same as main devlogs API)
16+
// Parse filterType parameter first (has precedence over individual status filtering)
17+
const filterType = searchParams.get('filterType') as FilterType;
18+
if (filterType) {
19+
const statusArray = filterTypeToStatusFilter(filterType);
20+
if (statusArray) {
21+
filter.status = statusArray;
22+
}
23+
// If filterType is 'total', statusArray will be undefined and no status filtering is applied
24+
}
25+
26+
// Parse other query parameters (same as main devlogs API)
27+
// Note: individual status parameter will override filterType if both are provided
1628
if (searchParams.get('status')) filter.status = searchParams.get('status')?.split(',');
1729
if (searchParams.get('type')) filter.type = searchParams.get('type');
1830
if (searchParams.get('priority')) filter.priority = searchParams.get('priority');

0 commit comments

Comments
 (0)