mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-08 14:56:19 +02:00
The Assign dropdown now sorts members and agents by how frequently the current user assigns issues to them. Frequency is computed from two sources: assignee_changed activities in the activity log and initial assignments on issues created by the user. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
27 lines
782 B
SQL
27 lines
782 B
SQL
-- name: ListActivities :many
|
|
SELECT * FROM activity_log
|
|
WHERE issue_id = $1
|
|
ORDER BY created_at ASC
|
|
LIMIT $2 OFFSET $3;
|
|
|
|
-- name: CreateActivity :one
|
|
INSERT INTO activity_log (
|
|
workspace_id, issue_id, actor_type, actor_id, action, details
|
|
) VALUES ($1, $2, $3, $4, $5, $6)
|
|
RETURNING *;
|
|
|
|
-- name: CountAssigneeChangesByActor :many
|
|
-- Count how many times a user assigned each target via assignee_changed activities.
|
|
SELECT
|
|
details->>'to_type' as assignee_type,
|
|
details->>'to_id' as assignee_id,
|
|
COUNT(*)::bigint as frequency
|
|
FROM activity_log
|
|
WHERE workspace_id = $1
|
|
AND actor_id = $2
|
|
AND actor_type = 'member'
|
|
AND action = 'assignee_changed'
|
|
AND details->>'to_type' IS NOT NULL
|
|
AND details->>'to_id' IS NOT NULL
|
|
GROUP BY details->>'to_type', details->>'to_id';
|