add mcp label

This commit is contained in:
2026-09-06 02:07:36 +07:00
parent 97ad956a6b
commit ef86674fce
9 changed files with 333 additions and 216 deletions
+14 -7
View File
@@ -15,6 +15,11 @@ type ActionsRepo struct {
pool *pgxpool.Pool
}
type Action struct {
Code string
ViaMCP bool
}
func NewActionsRepo(pool *pgxpool.Pool) *ActionsRepo {
return &ActionsRepo{
pool: pool,
@@ -39,11 +44,12 @@ func (r *ActionsRepo) AddAction(ctx context.Context, teamId int, code string, vi
return id, nil
}
func (r *ActionsRepo) GetActionsByTeamID(ctx context.Context, teamId int) ([]string, error) {
func (r *ActionsRepo) GetActionsByTeamID(ctx context.Context, teamId int) ([]Action, error) {
rows, err := r.pool.Query(
ctx,
`SELECT
code
code,
via_mcp
FROM actions
WHERE team_id = $1
ORDER BY created_at ASC`,
@@ -54,22 +60,23 @@ func (r *ActionsRepo) GetActionsByTeamID(ctx context.Context, teamId int) ([]str
}
defer rows.Close()
var codes []string
var actions []Action
for rows.Next() {
code := ""
action := Action{}
err := rows.Scan(
&code,
&action.Code,
&action.ViaMCP,
)
if err != nil {
return nil, err
}
codes = append(codes, code)
actions = append(actions, action)
}
if err := rows.Err(); err != nil {
return nil, err
}
return codes, nil
return actions, nil
}
func (r *ActionsRepo) GetActionsCountByTeamIDs(ctx context.Context, teamIds []int) (map[int]int, error) {