project summaries addition
This commit is contained in:
@@ -50,4 +50,27 @@ function deleteSummary(id) {
|
||||
getDB().prepare(`DELETE FROM summaries WHERE id = ?`).run(id);
|
||||
}
|
||||
|
||||
module.exports = { createSummary, getSummary, getSummariesBySession, getSummariesByProject, updateSummary, deleteSummary };
|
||||
// Fetches session summaries that belong to sessions in a given project
|
||||
// Joins through sessions table since session summaries don't store project_id directly
|
||||
function getSessionSummariesForProject(projectId) {
|
||||
const db = getDB();
|
||||
return db.prepare(`
|
||||
SELECT s.* FROM summaries s
|
||||
JOIN sessions sess ON sess.id = s.session_id
|
||||
WHERE sess.project_id = ? AND s.session_id IS NOT NULL
|
||||
ORDER BY s.created_at ASC
|
||||
`).all(projectId).map(parseRow);
|
||||
}
|
||||
|
||||
// Fetches the most recent project-level overview summary (session_id IS NULL distinguishes it)
|
||||
function getProjectOverviewSummary(projectId) {
|
||||
const db = getDB();
|
||||
const row = db.prepare(`
|
||||
SELECT * FROM summaries
|
||||
WHERE project_id = ? AND session_id IS NULL
|
||||
ORDER BY created_at DESC LIMIT 1
|
||||
`).get(projectId);
|
||||
return row ? parseRow(row) : null;
|
||||
}
|
||||
|
||||
module.exports = { createSummary, getSummary, getSummariesBySession, getSummariesByProject, updateSummary, deleteSummary, getSessionSummariesForProject, getProjectOverviewSummary };
|
||||
Reference in New Issue
Block a user