use beads service

use pointes for comments
use htmx routing
This commit is contained in:
Robin Olsen
2026-02-22 11:03:31 +01:00
parent 15f8bbb8ed
commit 2e4185e30f
12 changed files with 403 additions and 358 deletions

View File

@@ -51,48 +51,3 @@ func (s *BeadsService) DeleteIssues() error {
}
return nil
}
func (s *BeadsService) GetComments(ctx context.Context, issueID string) ([]models.Comment, error) {
query := `SELECT id, issue_id, author, text, created_at FROM comments WHERE issue_id = ? ORDER BY created_at ASC LIMIT 100`
rows, err := s.UnderlyingDB().QueryContext(ctx, query, issueID)
if err != nil {
return nil, err
}
if len(commentsPtr) == 0 {
return []models.Comment{}, nil
}
comments := make([]models.Comment, 0, len(commentsPtr))
for _, c := range commentsPtr {
if c != nil {
comments = append(comments, *c)
}
}
return comments, nil
}
func (s *BeadsService) AddComment(ctx context.Context, issueID, author, text string) (*models.Comment, error) {
query := `INSERT INTO comments (issue_id, author, text, created_at) VALUES (?, ?, ?, ?)`
createdAt := time.Now().UTC()
result, err := s.UnderlyingDB().ExecContext(ctx, query, issueID, author, text, createdAt)
if err != nil {
return nil, err
}
id, err := result.LastInsertId()
if err != nil {
return nil, err
}
return &models.Comment{
ID: id,
IssueID: issueID,
Author: author,
Text: text,
CreatedAt: createdAt,
}, nil
}