this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add getProjects and updateProjectStatus db functions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

alice 9be5d25c d6abd543

+52
+52
src/core/db.ts
··· 12 12 DayDetail, 13 13 ProjectDetail, 14 14 SessionDetail, 15 + ProjectStatus, 16 + ProjectListItem, 15 17 } from '../types'; 16 18 17 19 const DATA_DIR = join(import.meta.dir, '../../data'); ··· 308 310 .filter((p) => isNewProject(p.project_path, date)) 309 311 .map((p) => p.project_path); 310 312 } 313 + 314 + // Project management 315 + export function getProjects(status?: ProjectStatus): ProjectListItem[] { 316 + const database = getDb(); 317 + const today = new Date().toISOString().split('T')[0]; 318 + 319 + const query = status 320 + ? `SELECT * FROM projects WHERE status = ? ORDER BY last_session_date DESC` 321 + : `SELECT * FROM projects ORDER BY last_session_date DESC`; 322 + 323 + const rows = status 324 + ? database.query<{ 325 + project_path: string; 326 + project_name: string; 327 + status: string; 328 + total_sessions: number; 329 + last_session_date: string; 330 + }, [string]>(query).all(status) 331 + : database.query<{ 332 + project_path: string; 333 + project_name: string; 334 + status: string; 335 + total_sessions: number; 336 + last_session_date: string; 337 + }, []>(query).all(); 338 + 339 + return rows.map((row) => { 340 + const lastDate = new Date(row.last_session_date); 341 + const todayDate = new Date(today); 342 + const diffTime = todayDate.getTime() - lastDate.getTime(); 343 + const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24)); 344 + 345 + return { 346 + path: row.project_path, 347 + name: row.project_name, 348 + status: row.status as ProjectStatus, 349 + totalSessions: row.total_sessions, 350 + daysSinceLastSession: diffDays, 351 + }; 352 + }); 353 + } 354 + 355 + export function updateProjectStatus(projectPath: string, status: ProjectStatus): boolean { 356 + const database = getDb(); 357 + const result = database.run( 358 + `UPDATE projects SET status = ?, updated_at = ? WHERE project_path = ?`, 359 + [status, new Date().toISOString(), projectPath] 360 + ); 361 + return result.changes > 0; 362 + }