index

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDBPath

func DefaultDBPath() string

DefaultDBPath returns the path to the index database (~/.human/index.db), creating the directory if needed.

Types

type Entry

type Entry struct {
	Key       string    `json:"key"`
	Source    string    `json:"source"` // instance name
	Kind      string    `json:"kind"`   // "jira", "github", etc.
	Project   string    `json:"project"`
	Title     string    `json:"title"`
	Status    string    `json:"status"`
	Assignee  string    `json:"assignee"`
	URL       string    `json:"url"` // instance base URL
	IndexedAt time.Time `json:"indexed_at"`
}

Entry holds the metadata for a single indexed issue.

type NotionClient

type NotionClient interface {
	Search(ctx context.Context, query string) ([]notion.SearchResult, error)
	GetPage(ctx context.Context, pageID string) (string, error)
	ListDatabases(ctx context.Context) ([]notion.DatabaseEntry, error)
	QueryDatabase(ctx context.Context, dbID string) ([]notion.DatabaseRow, error)
}

NotionClient is the subset of notion.Client methods needed by SyncNotion.

type NotionInstance

type NotionInstance struct {
	Name   string
	URL    string
	Client NotionClient
}

NotionInstance holds a configured Notion workspace for indexing.

type SQLiteStore

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

SQLiteStore implements Store using SQLite with FTS5 full-text search.

func NewSQLiteStore

func NewSQLiteStore(dbPath string) (*SQLiteStore, error)

NewSQLiteStore opens (or creates) a SQLite database at dbPath and ensures the schema is up to date. Use ":memory:" for in-memory databases in tests.

func (*SQLiteStore) AllKeys

func (s *SQLiteStore) AllKeys(ctx context.Context, source string) ([]string, error)

AllKeys returns all indexed keys for a given source instance.

func (*SQLiteStore) Close

func (s *SQLiteStore) Close() error

Close closes the database connection.

func (*SQLiteStore) DeleteEntry

func (s *SQLiteStore) DeleteEntry(ctx context.Context, key, source string) error

DeleteEntry removes an entry and its FTS index.

func (*SQLiteStore) LastIndexedAt

func (s *SQLiteStore) LastIndexedAt(ctx context.Context, source string) (time.Time, error)

LastIndexedAt returns the most recent indexed_at timestamp for a given source. Returns the zero time if no entries exist for the source.

func (*SQLiteStore) Search

func (s *SQLiteStore) Search(ctx context.Context, query string, limit int) ([]Entry, error)

Search performs a full-text search and returns matching entries ranked by BM25.

func (*SQLiteStore) Stats

func (s *SQLiteStore) Stats(ctx context.Context) (*Stats, error)

Stats returns statistics about the index.

func (*SQLiteStore) UpsertEntry

func (s *SQLiteStore) UpsertEntry(ctx context.Context, entry Entry, description string) error

UpsertEntry inserts or updates an entry and its FTS index.

type Stats

type Stats struct {
	TotalEntries  int            `json:"total_entries"`
	LastIndexedAt time.Time      `json:"last_indexed_at"`
	ByKind        map[string]int `json:"by_kind"`
	BySource      map[string]int `json:"by_source"`
}

Stats summarises the current state of the index.

type Store

type Store interface {
	UpsertEntry(ctx context.Context, entry Entry, description string) error
	DeleteEntry(ctx context.Context, key, source string) error
	Search(ctx context.Context, query string, limit int) ([]Entry, error)
	Stats(ctx context.Context) (*Stats, error)
	AllKeys(ctx context.Context, source string) ([]string, error)
	LastIndexedAt(ctx context.Context, source string) (time.Time, error)
	Close() error
}

Store is the persistence interface for the search index.

type SyncNotionResult

type SyncNotionResult struct {
	Pages     int
	Databases int
	Pruned    int
	Errors    int
}

SyncNotionResult summarises one Notion sync run.

func SyncNotion

func SyncNotion(ctx context.Context, store Store, instances []NotionInstance, logger io.Writer) (*SyncNotionResult, error)

SyncNotion iterates all Notion instances, discovers pages and databases, fetches content, upserts entries, and prunes stale keys.

type SyncResult

type SyncResult struct {
	Indexed int
	Pruned  int
	Errors  int
}

SyncResult summarises one sync run.

func Sync

func Sync(ctx context.Context, store Store, instances []tracker.Instance, fullSync bool, logger io.Writer) (*SyncResult, error)

Sync iterates all instances, lists issues per configured project, fetches descriptions, upserts entries, and prunes stale keys. When fullSync is false, it performs incremental sync using the last indexed timestamp per source to only fetch recently updated issues.

Jump to

Keyboard shortcuts

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