Feat v0.3.4 team roles signoff (#18)
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #18.
This commit is contained in:
@@ -686,6 +686,50 @@ func (s *WorkflowStore) ListAssignmentsByUser(ctx context.Context, userID string
|
||||
return s.queryAssignments(ctx, q, args...)
|
||||
}
|
||||
|
||||
// ── Signoffs (v0.3.4) ─────────────────────────
|
||||
|
||||
func (s *WorkflowStore) CreateSignoff(ctx context.Context, so *models.WorkflowSignoff) error {
|
||||
so.ID = store.NewID()
|
||||
so.CreatedAt = time.Now().UTC()
|
||||
_, err := DB.ExecContext(ctx, `
|
||||
INSERT INTO workflow_signoffs (id, instance_id, stage, user_id, decision, comment, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
||||
so.ID, so.InstanceID, so.Stage, so.UserID, so.Decision, so.Comment,
|
||||
so.CreatedAt.Format(timeFmt))
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *WorkflowStore) ListSignoffs(ctx context.Context, instanceID, stage string) ([]models.WorkflowSignoff, error) {
|
||||
rows, err := DB.QueryContext(ctx, `
|
||||
SELECT id, instance_id, stage, user_id, decision, comment, created_at
|
||||
FROM workflow_signoffs
|
||||
WHERE instance_id = ? AND stage = ?
|
||||
ORDER BY created_at`, instanceID, stage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var result []models.WorkflowSignoff
|
||||
for rows.Next() {
|
||||
var so models.WorkflowSignoff
|
||||
if err := rows.Scan(&so.ID, &so.InstanceID, &so.Stage, &so.UserID,
|
||||
&so.Decision, &so.Comment, st(&so.CreatedAt)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result, so)
|
||||
}
|
||||
return result, rows.Err()
|
||||
}
|
||||
|
||||
func (s *WorkflowStore) CountSignoffs(ctx context.Context, instanceID, stage, decision string) (int, error) {
|
||||
var count int
|
||||
err := DB.QueryRowContext(ctx, `
|
||||
SELECT COUNT(*) FROM workflow_signoffs
|
||||
WHERE instance_id = ? AND stage = ? AND decision = ?`,
|
||||
instanceID, stage, decision).Scan(&count)
|
||||
return count, err
|
||||
}
|
||||
|
||||
func (s *WorkflowStore) queryAssignments(ctx context.Context, q string, args ...interface{}) ([]models.WorkflowAssignment, error) {
|
||||
rows, err := DB.QueryContext(ctx, q, args...)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user