feat(projects): gather the cards one member carries
A board answers "where does the work stand". Nobody opens a dashboard to ask that first: they ask what is on them today, and once the work is spread over several boards no single board can answer it. The cards assigned to a member are now listed on a page of their own, grouped by deadline, with a counter on the sidebar entry — a page you have to open to know whether it needs you is a page you stop opening. The column travels with each card, so finishing one from the list is a single move rather than a detour through its board. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
d2256e2211
commit
fcc82d82d6
6 files changed
+732
-6
No files matched your search
@@ -270,16 +270,60 @@ export function removeCard(id) {
|
||||
return getDatabase().prepare('DELETE FROM project_cards WHERE id = ?').run(id).changes;
|
||||
}
|
||||
|
||||
/** Cards carried by one member, across every board of the guild. */
|
||||
const parseAssignedCard = (row) => ({
|
||||
...parseCard(row),
|
||||
column_is_done: Boolean(row.column_is_done),
|
||||
});
|
||||
|
||||
/**
|
||||
* Cards carried by one member, across every board of the guild (M19).
|
||||
*
|
||||
* The column travels with the card: « what am I on today » cannot be answered
|
||||
* without knowing whether a card is still open, and asking per card turns the
|
||||
* page into a staircase of queries. `done_column_id` comes along for the same
|
||||
* reason — finishing a card from here is then a single move.
|
||||
*/
|
||||
export function listCardsForAssignee(guildId, assigneeId) {
|
||||
return getDatabase()
|
||||
.prepare(
|
||||
`SELECT c.*, b.name AS board_name, b.repository
|
||||
`SELECT c.*,
|
||||
b.name AS board_name,
|
||||
b.scope AS board_scope,
|
||||
b.repository,
|
||||
col.name AS column_name,
|
||||
col.is_done AS column_is_done,
|
||||
(SELECT d.id FROM project_columns d
|
||||
WHERE d.board_id = b.id AND d.is_done = 1
|
||||
ORDER BY d.position, d.id LIMIT 1) AS done_column_id
|
||||
FROM project_cards c
|
||||
JOIN project_boards b ON b.id = c.board_id
|
||||
JOIN project_columns col ON col.id = c.column_id
|
||||
WHERE b.guild_id = ? AND c.assignee_id = ?
|
||||
ORDER BY c.due_at IS NULL, c.due_at, c.id`,
|
||||
)
|
||||
.all(guildId, assigneeId)
|
||||
.map(parseCard);
|
||||
.map(parseAssignedCard);
|
||||
}
|
||||
|
||||
/**
|
||||
* Who carries cards, and how many are still open.
|
||||
*
|
||||
* Lets the page offer a picker without asking Discord for the member list,
|
||||
* which is unavailable whenever the bot is offline — precisely when someone is
|
||||
* most likely to be looking at the dashboard.
|
||||
*/
|
||||
export function listAssignees(guildId) {
|
||||
return getDatabase()
|
||||
.prepare(
|
||||
`SELECT c.assignee_id AS assigneeId,
|
||||
COUNT(*) AS total,
|
||||
SUM(CASE WHEN col.is_done = 1 THEN 0 ELSE 1 END) AS open
|
||||
FROM project_cards c
|
||||
JOIN project_boards b ON b.id = c.board_id
|
||||
JOIN project_columns col ON col.id = c.column_id
|
||||
WHERE b.guild_id = ? AND c.assignee_id IS NOT NULL AND c.assignee_id <> ''
|
||||
GROUP BY c.assignee_id
|
||||
ORDER BY open DESC, total DESC`,
|
||||
)
|
||||
.all(guildId);
|
||||
}
|
||||
Reference in new issue
Block a user