store

package
v0.0.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSyncStateNotFound = errors.New("sync state key not found")
View Source
var GitHubSourceFields = []string{
	"name",
	"description",
	"url",
	"language",
	"homepage",
	"stargazers_count",
	"forks_count",
	"topics",
	"owner_login",
	"owner_avatar",
	"starred_at",
}
View Source
var LocalRepoFields = []string{
	"ai_summary",
	"ai_tags",
	"ai_platforms",
	"ai_search_text",
	"ai_category",
	"analyzed_at",
	"analysis_failed",
	"custom_description",
	"custom_tags",
	"custom_category",
	"category_locked",
	"last_released",
	"subscribed_releases",
	"last_release_fetch",
}

Functions

This section is empty.

Types

type AIResult

type AIResult struct {
	Summary    string
	Tags       []string
	Platforms  []string
	Category   string
	SearchText string
}

type Category

type Category struct {
	ID        string
	Name      string
	Keywords  []string
	SortOrder int
	IsCustom  bool
	IsHidden  bool
}

type CustomFields

type CustomFields struct {
	Description    string
	Tags           []string
	Category       string
	CategoryLocked bool
}

type FTSResult deprecated added in v0.0.5

type FTSResult struct {
	Repo      *Repository
	BM25Score float64
}

Deprecated: FTSResult was used for FTS5 full-text search results. In-memory search now uses ai.SearchHit directly. This type is retained for backward compatibility and may be removed.

type Release

type Release struct {
	ID           int64
	RepoID       int64
	RepoFullName string
	TagName      string
	Name         string
	Body         string
	HTMLURL      string
	PublishedAt  string
	IsPrerelease bool
	IsDraft      bool
	IsRead       bool
	Assets       []ReleaseAsset
}

type ReleaseAsset

type ReleaseAsset struct {
	Name        string `json:"name"`
	URL         string `json:"url"`
	Size        int64  `json:"size"`
	ContentType string `json:"content_type"`
}

type Repository

type Repository struct {
	ID                 int64
	FullName           string
	Name               string
	Description        string
	URL                string
	Language           string
	Homepage           string
	StargazersCount    int
	ForksCount         int
	Topics             []string
	OwnerLogin         string
	OwnerAvatar        string
	StarredAt          string
	AISummary          string
	AITags             []string
	AIPlatforms        []string
	AICategory         string
	AISearchText       string
	AnalyzedAt         *time.Time
	AnalysisFailed     bool
	CustomDescription  string
	CustomTags         []string
	CustomCategory     string
	CategoryLocked     bool
	SubscribedReleases bool
	LastReleaseFetch   *time.Time
	VectorIndexedAt    *time.Time
}

func MergeReposOnSync added in v0.0.6

func MergeReposOnSync(incoming []*Repository, existing map[string]*Repository) []*Repository

type SearchFilters added in v0.0.5

type SearchFilters struct {
	Language       string
	Category       string
	MinStars       int
	MaxStars       int
	Platform       string
	Tags           []string
	Limit          int
	Analyzed       *bool
	AnalysisFailed *bool
}

type Store

type Store interface {
	Close() error

	UpsertRepository(ctx context.Context, r *Repository) error
	UpsertRepositories(ctx context.Context, rs []*Repository) error
	UpsertReposOnSync(ctx context.Context, rs []*Repository, fullSync bool) error
	GetRepository(ctx context.Context, fullName string) (*Repository, error)
	ListRepositories(ctx context.Context) ([]*Repository, error)
	ListUnanalyzed(ctx context.Context, limit int) ([]*Repository, error)
	ListByCategory(ctx context.Context, category string) ([]*Repository, error)
	UpdateAIResult(ctx context.Context, repoID int64, res *AIResult) error
	UpdateCustomFields(ctx context.Context, repoID int64, f *CustomFields) error
	SetAnalysisFailed(ctx context.Context, repoID int64, failed bool) error
	DeleteAllRepositories(ctx context.Context) error

	// Deprecated: SearchFTS used FTS5 for full-text search.
	// Search is now handled by in-memory matching in the ai package (SearchIndex).
	// This method remains for backward compatibility and may be removed in a future version.
	SearchFTS(ctx context.Context, query string, filters *SearchFilters) ([]*FTSResult, error)
	// Deprecated: RebuildFTSIndex was used to refresh the FTS5 full-text index.
	// This method remains for backward compatibility and may be removed in a future version.
	RebuildFTSIndex(ctx context.Context) error

	InsertVector(ctx context.Context, repoID int64, embedding []float64) error
	SearchVectors(ctx context.Context, queryVec []float64, topK int, threshold float64) ([]VectorMatch, error)
	DeleteVector(ctx context.Context, repoID int64) error
	SetVectorIndexedAt(ctx context.Context, repoID int64, t time.Time) error
	GetRepositoryByID(ctx context.Context, id int64) (*Repository, error)
	ListVectorUnindexed(ctx context.Context, limit int) ([]*Repository, error)
	EnsureVec0Dimension(ctx context.Context, dim int) error

	UpsertRelease(ctx context.Context, r *Release) error
	ListUnreadReleases(ctx context.Context) ([]*Release, error)
	ListAllReleases(ctx context.Context) ([]*Release, error)
	ListReleasesByRepo(ctx context.Context, repoFullName string) ([]*Release, error)
	MarkReleaseRead(ctx context.Context, releaseID int64) error
	MarkAllReleasesRead(ctx context.Context) error
	SetReleaseSubscription(ctx context.Context, repoFullName string, subscribed bool) error
	UpdateReleaseWatermark(ctx context.Context, repoID int64, t time.Time) error

	ListCategories(ctx context.Context, visibleOnly bool) ([]*Category, error)
	UpsertCategory(ctx context.Context, c *Category) error
	DeleteCategory(ctx context.Context, id string) error

	GetSyncState(ctx context.Context, key string) (string, error)
	SetSyncState(ctx context.Context, key, value string) error
	SaveSyncStats(ctx context.Context, stats *SyncStats) error
	GetSyncStats(ctx context.Context) (*SyncStats, error)
	IncrementSyncCount(ctx context.Context) error
}

func Open

func Open(dbPath string) (Store, error)

type SyncStats added in v0.0.6

type SyncStats struct {
	TotalSyncCount int       `json:"total_sync_count"`
	LastSync       time.Time `json:"last_sync"`
	LastDuration   string    `json:"last_duration"`
	LastRepoCount  int       `json:"last_repo_count"`
	LastNewCount   int       `json:"last_new_count"`
	LastErrorCount int       `json:"last_error_count"`
}

type VectorMatch added in v0.0.6

type VectorMatch struct {
	RepoID     int64
	Distance   float64
	Similarity float64
}

Jump to

Keyboard shortcuts

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