storage

package
v0.0.0-...-2323d9c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package storage handles persistence of tickets to JSONL and SQLite.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendComment

func AppendComment(path string, c *ticket.Comment) error

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

func AppendJSONL(path string, t *ticket.Ticket) error

AppendJSONL appends a single ticket to the JSONL file by rewriting it sorted.

func GetJSONLModTime

func GetJSONLModTime(path string) (int64, error)

GetJSONLModTime returns the modification time of the JSONL file.

func ReadAllJSONL

func ReadAllJSONL(path string) ([]*ticket.Ticket, []*ticket.Comment, []*ticket.Dependency, error)

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 ReadJSONL

func ReadJSONL(path string) ([]*ticket.Ticket, error)

ReadJSONL reads all tickets from a JSONL file, ignoring comments and dependencies.

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.

func WriteJSONL

func WriteJSONL(path string, tickets []*ticket.Ticket) error

WriteJSONL writes all tickets 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 OpenDB

func OpenDB(path string) (*DB, error)

OpenDB opens or creates a SQLite database at the given path.

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection.

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

func (db *DB) GetAllComments() ([]*ticket.Comment, error)

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

func (db *DB) GetAllTickets() ([]*ticket.Ticket, error)

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

func (db *DB) GetCommentsForTicket(ticketID string) ([]*ticket.Comment, error)

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

func (db *DB) GetMetadata(key string) (string, error)

GetMetadata retrieves a metadata value by key.

func (*DB) GetTicket

func (db *DB) GetTicket(id string) (*ticket.Ticket, error)

GetTicket retrieves a ticket by ID.

func (*DB) InsertComment

func (db *DB) InsertComment(c *ticket.Comment) error

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

func (db *DB) InsertTicket(t *ticket.Ticket) error

InsertTicket adds a new ticket to the database.

func (*DB) ListReadyTickets

func (db *DB) ListReadyTickets() ([]*ticket.Ticket, error)

ListReadyTickets retrieves open tickets that are not blocked by other open tickets.

func (*DB) ListTickets

func (db *DB) ListTickets(status *ticket.Status) ([]*ticket.Ticket, error)

ListTickets retrieves tickets with optional status filter, ordered by priority.

func (*DB) ListTicketsByLabel

func (db *DB) ListTicketsByLabel(label string, status *ticket.Status) ([]*ticket.Ticket, error)

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

func (db *DB) RebuildFromTickets(tickets []*ticket.Ticket) error

RebuildFromTickets clears all tickets and inserts the given list.

func (*DB) SetMetadata

func (db *DB) SetMetadata(key, value string) error

SetMetadata stores a metadata key-value pair.

func (*DB) UpdateTicket

func (db *DB) UpdateTicket(t *ticket.Ticket) error

UpdateTicket updates an existing ticket in the database.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store provides synchronized access to ticket storage.

func Open

func Open(paths config.Paths) (*Store, error)

Open creates a new Store, opening the SQLite database and syncing from JSONL if needed.

func (*Store) Add

func (s *Store) Add(t *ticket.Ticket) error

Add creates a new ticket and persists it to both JSONL and SQLite.

func (*Store) AddComment

func (s *Store) AddComment(c *ticket.Comment) error

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) Close

func (s *Store) Close() error

Close closes the underlying database.

func (*Store) Get

func (s *Store) Get(id string) (*ticket.Ticket, error)

Get retrieves a ticket by ID.

func (*Store) GetBlockers

func (s *Store) GetBlockers(ticketID string) ([]*ticket.Ticket, error)

GetBlockers retrieves tickets that block the given ticket (blocked_by dependencies).

func (*Store) GetBlocking

func (s *Store) GetBlocking(ticketID string) ([]*ticket.Ticket, error)

GetBlocking retrieves tickets that are blocked by the given ticket.

func (*Store) GetComments

func (s *Store) GetComments(ticketID string) ([]*ticket.Comment, error)

GetComments retrieves all comments for a ticket.

func (*Store) GetCreatedFrom

func (s *Store) GetCreatedFrom(ticketID string) (*ticket.Ticket, error)

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) IsBlocked

func (s *Store) IsBlocked(ticketID string) (bool, error)

IsBlocked checks if a ticket has any open blocking dependencies.

func (*Store) List

func (s *Store) List(status *ticket.Status) ([]*ticket.Ticket, error)

List retrieves tickets with optional status filter.

func (*Store) ListAllComments

func (s *Store) ListAllComments() ([]*ticket.Comment, error)

ListAllComments retrieves all comments from storage.

func (*Store) ListByLabel

func (s *Store) ListByLabel(label string, status *ticket.Status) ([]*ticket.Ticket, error)

ListByLabel retrieves tickets with the specified label.

func (*Store) ListReady

func (s *Store) ListReady() ([]*ticket.Ticket, error)

ListReady retrieves open tickets that are not blocked by other open tickets.

func (*Store) SyncFromJSONL

func (s *Store) SyncFromJSONL() error

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.

func (*Store) Update

func (s *Store) Update(t *ticket.Ticket) error

Update modifies an existing ticket in both JSONL and SQLite.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL