Documentation
¶
Overview ¶
Package storage handles persistence of tickets to JSONL and SQLite.
Index ¶
- func AppendComment(path string, c *ticket.Comment) error
- func AppendDependency(path string, d *ticket.Dependency) error
- func AppendJSONL(path string, t *ticket.Ticket) error
- func GetJSONLModTime(path string) (int64, error)
- func ReadAllJSONL(path string) ([]*ticket.Ticket, []*ticket.Comment, []*ticket.Dependency, error)
- func ReadJSONL(path string) ([]*ticket.Ticket, error)
- func WriteAllJSONL(path string, tickets []*ticket.Ticket, comments []*ticket.Comment, ...) error
- func WriteJSONL(path string, tickets []*ticket.Ticket) error
- type DB
- func (db *DB) Close() error
- func (db *DB) DependencyExists(fromTicketID, toTicketID string, depType ticket.DependencyType) (bool, error)
- func (db *DB) GetAllComments() ([]*ticket.Comment, error)
- func (db *DB) GetAllDependencies() ([]*ticket.Dependency, error)
- func (db *DB) GetAllTickets() ([]*ticket.Ticket, error)
- func (db *DB) GetBlockingDependencies() ([]*ticket.Dependency, error)
- func (db *DB) GetCommentsForTicket(ticketID string) ([]*ticket.Comment, error)
- func (db *DB) GetDependenciesFrom(ticketID string) ([]*ticket.Dependency, error)
- func (db *DB) GetDependenciesTo(ticketID string) ([]*ticket.Dependency, error)
- func (db *DB) GetMetadata(key string) (string, error)
- func (db *DB) GetTicket(id string) (*ticket.Ticket, error)
- func (db *DB) InsertComment(c *ticket.Comment) error
- func (db *DB) InsertDependency(d *ticket.Dependency) error
- func (db *DB) InsertTicket(t *ticket.Ticket) error
- func (db *DB) ListReadyTickets() ([]*ticket.Ticket, error)
- func (db *DB) ListTickets(status *ticket.Status) ([]*ticket.Ticket, error)
- func (db *DB) ListTicketsByLabel(label string, status *ticket.Status) ([]*ticket.Ticket, error)
- func (db *DB) RebuildFromAll(tickets []*ticket.Ticket, comments []*ticket.Comment, ...) error
- func (db *DB) RebuildFromTickets(tickets []*ticket.Ticket) error
- func (db *DB) SetMetadata(key, value string) error
- func (db *DB) UpdateTicket(t *ticket.Ticket) error
- type Store
- func (s *Store) Add(t *ticket.Ticket) error
- func (s *Store) AddComment(c *ticket.Comment) error
- func (s *Store) AddDependency(d *ticket.Dependency) error
- func (s *Store) Close() error
- func (s *Store) Get(id string) (*ticket.Ticket, error)
- func (s *Store) GetBlockers(ticketID string) ([]*ticket.Ticket, error)
- func (s *Store) GetBlocking(ticketID string) ([]*ticket.Ticket, error)
- func (s *Store) GetComments(ticketID string) ([]*ticket.Comment, error)
- func (s *Store) GetCreatedFrom(ticketID string) (*ticket.Ticket, error)
- func (s *Store) GetDependenciesFrom(ticketID string) ([]*ticket.Dependency, error)
- func (s *Store) GetDependenciesTo(ticketID string) ([]*ticket.Dependency, error)
- func (s *Store) IsBlocked(ticketID string) (bool, error)
- func (s *Store) List(status *ticket.Status) ([]*ticket.Ticket, error)
- func (s *Store) ListAllComments() ([]*ticket.Comment, error)
- func (s *Store) ListByLabel(label string, status *ticket.Status) ([]*ticket.Ticket, error)
- func (s *Store) ListReady() ([]*ticket.Ticket, error)
- func (s *Store) SyncFromJSONL() error
- func (s *Store) Update(t *ticket.Ticket) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendComment ¶
AppendComment appends a single comment to the JSONL file by rewriting it sorted.
func AppendDependency ¶
func AppendDependency(path string, d *ticket.Dependency) error
AppendDependency appends a single dependency to the JSONL file by rewriting it sorted.
func AppendJSONL ¶
AppendJSONL appends a single ticket to the JSONL file by rewriting it sorted.
func GetJSONLModTime ¶
GetJSONLModTime returns the modification time of the JSONL file.
func ReadAllJSONL ¶
ReadAllJSONL reads all tickets, comments, and dependencies from a JSONL file. It distinguishes between record types by checking for specific fields: - Dependencies have from_ticket_id - Comments have ticket_id - Tickets have neither
func WriteAllJSONL ¶
func WriteAllJSONL(path string, tickets []*ticket.Ticket, comments []*ticket.Comment, dependencies []*ticket.Dependency) error
WriteAllJSONL writes all tickets, comments, and dependencies to a JSONL file, replacing existing content and sorting by ID.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps a SQLite database connection for ticket operations.
func (*DB) DependencyExists ¶
func (db *DB) DependencyExists(fromTicketID, toTicketID string, depType ticket.DependencyType) (bool, error)
DependencyExists checks if a specific dependency already exists.
func (*DB) GetAllComments ¶
GetAllComments retrieves all comments from the database.
func (*DB) GetAllDependencies ¶
func (db *DB) GetAllDependencies() ([]*ticket.Dependency, error)
GetAllDependencies retrieves all dependencies from the database.
func (*DB) GetAllTickets ¶
GetAllTickets retrieves all tickets from the database.
func (*DB) GetBlockingDependencies ¶
func (db *DB) GetBlockingDependencies() ([]*ticket.Dependency, error)
GetBlockingDependencies retrieves all blocked_by dependencies from the database.
func (*DB) GetCommentsForTicket ¶
GetCommentsForTicket retrieves all comments for a ticket, ordered by creation time.
func (*DB) GetDependenciesFrom ¶
func (db *DB) GetDependenciesFrom(ticketID string) ([]*ticket.Dependency, error)
GetDependenciesFrom retrieves all dependencies from a specific ticket.
func (*DB) GetDependenciesTo ¶
func (db *DB) GetDependenciesTo(ticketID string) ([]*ticket.Dependency, error)
GetDependenciesTo retrieves all dependencies pointing to a specific ticket.
func (*DB) GetMetadata ¶
GetMetadata retrieves a metadata value by key.
func (*DB) InsertComment ¶
InsertComment adds a new comment to the database.
func (*DB) InsertDependency ¶
func (db *DB) InsertDependency(d *ticket.Dependency) error
InsertDependency adds a new dependency to the database.
func (*DB) InsertTicket ¶
InsertTicket adds a new ticket to the database.
func (*DB) ListReadyTickets ¶
ListReadyTickets retrieves open tickets that are not blocked by other open tickets.
func (*DB) ListTickets ¶
ListTickets retrieves tickets with optional status filter, ordered by priority.
func (*DB) ListTicketsByLabel ¶
ListTicketsByLabel retrieves tickets that have the specified label.
func (*DB) RebuildFromAll ¶
func (db *DB) RebuildFromAll(tickets []*ticket.Ticket, comments []*ticket.Comment, dependencies []*ticket.Dependency) error
RebuildFromAll clears all tickets, comments, and dependencies and inserts the given lists.
func (*DB) RebuildFromTickets ¶
RebuildFromTickets clears all tickets and inserts the given list.
func (*DB) SetMetadata ¶
SetMetadata stores a metadata key-value pair.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides synchronized access to ticket storage.
func (*Store) AddComment ¶
AddComment creates a new comment and persists it to both JSONL and SQLite.
func (*Store) AddDependency ¶
func (s *Store) AddDependency(d *ticket.Dependency) error
AddDependency creates a new dependency and persists it to both JSONL and SQLite. For blocked_by dependencies, it validates that no circular dependency would be created.
func (*Store) GetBlockers ¶
GetBlockers retrieves tickets that block the given ticket (blocked_by dependencies).
func (*Store) GetBlocking ¶
GetBlocking retrieves tickets that are blocked by the given ticket.
func (*Store) GetComments ¶
GetComments retrieves all comments for a ticket.
func (*Store) GetCreatedFrom ¶
GetCreatedFrom retrieves the parent ticket that this ticket was created from.
func (*Store) GetDependenciesFrom ¶
func (s *Store) GetDependenciesFrom(ticketID string) ([]*ticket.Dependency, error)
GetDependenciesFrom retrieves all dependencies from a specific ticket.
func (*Store) GetDependenciesTo ¶
func (s *Store) GetDependenciesTo(ticketID string) ([]*ticket.Dependency, error)
GetDependenciesTo retrieves all dependencies pointing to a specific ticket.
func (*Store) ListAllComments ¶
ListAllComments retrieves all comments from storage.
func (*Store) ListByLabel ¶
ListByLabel retrieves tickets with the specified label.
func (*Store) ListReady ¶
ListReady retrieves open tickets that are not blocked by other open tickets.
func (*Store) SyncFromJSONL ¶
SyncFromJSONL checks if the JSONL file has been modified and rebuilds the cache if needed. This is useful when external processes modify the tickets file.