postgres

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func GetCNCFEntityAffiliations

func GetCNCFEntityAffiliations(ctx context.Context) (map[string]*data.CNCFDeveloper, error)

func RunSaaSMigrations

func RunSaaSMigrations(db *sql.DB) error

RunSaaSMigrations runs SaaS-specific migrations (tenant tables, RLS policies). Called by devpulse-cloud only, not the self-hosted CLI.

func UpdateDevelopersWithCNCFEntityAffiliations

func UpdateDevelopersWithCNCFEntityAffiliations(ctx context.Context, store data.DeveloperStore, entityStore data.EntityStore, client *http.Client) (*data.AffiliationImportResult, error)

UpdateDevelopersWithCNCFEntityAffiliations updates the developers with the CNCF entity affiliations. It accepts a data.DeveloperStore so it can be used with any Store implementation.

Types

type DBTX

type DBTX interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
}

DBTX is the common interface between *sql.DB and *sql.Conn. Both satisfy this interface natively — no adapter needed.

type Store

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

Store implements data.Store for PostgreSQL.

func New

func New(dsn string) (*Store, error)

New creates a new PostgreSQL Store, running migrations automatically.

func NewFromConn

func NewFromConn(conn *sql.Conn) *Store

NewFromConn creates a Store backed by a dedicated connection. Used for tenant-scoped requests where RLS requires set_config on a specific connection.

func NewFromEnv

func NewFromEnv() (*Store, error)

NewFromEnv creates a Store from DATABASE_URL env var, runs base + SaaS migrations.

func (*Store) ApplySubstitutions

func (s *Store) ApplySubstitutions(ctx context.Context) ([]*data.Substitution, error)

func (*Store) CleanEntities

func (s *Store) CleanEntities(ctx context.Context) error

func (*Store) ClearState

func (s *Store) ClearState(ctx context.Context, org, repo string) error

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database connection pool.

func (*Store) ComputeDeepReputation

func (s *Store) ComputeDeepReputation(ctx context.Context, token, username string) (*data.UserReputation, error)

func (*Store) DB

func (s *Store) DB() *sql.DB

DB returns the underlying *sql.DB for cases that need direct access.

func (*Store) DeleteRepoData

func (s *Store) DeleteRepoData(ctx context.Context, org, repo string) (*data.DeleteResult, error)

func (*Store) GetAllOrgRepos

func (s *Store) GetAllOrgRepos(ctx context.Context) ([]*data.OrgRepoItem, error)

func (*Store) GetChangeFailureRate

func (s *Store) GetChangeFailureRate(ctx context.Context, org, repo, entity *string, months int) (*data.ChangeFailureRateSeries, error)

func (*Store) GetContainerActivity

func (s *Store) GetContainerActivity(ctx context.Context, org, repo *string, months int) (*data.ContainerActivitySeries, error)

func (*Store) GetContributorFunnel

func (s *Store) GetContributorFunnel(ctx context.Context, org, repo, entity *string, months int) (*data.ContributorFunnelSeries, error)

func (*Store) GetContributorMomentum

func (s *Store) GetContributorMomentum(ctx context.Context, org, repo, entity *string, months int) (*data.MomentumSeries, error)

func (*Store) GetContributorProfile

func (s *Store) GetContributorProfile(ctx context.Context, username string, org, repo, entity *string, months int) (*data.ContributorProfileSeries, error)

func (*Store) GetContributorRetention

func (s *Store) GetContributorRetention(ctx context.Context, org, repo, entity *string, months int) (*data.RetentionSeries, error)

func (*Store) GetDailyActivity

func (s *Store) GetDailyActivity(ctx context.Context, org, repo, entity *string, months int) (*data.DailyActivitySeries, error)

func (*Store) GetDataState

func (s *Store) GetDataState(ctx context.Context) (map[string]int64, error)

func (*Store) GetDeveloper

func (s *Store) GetDeveloper(ctx context.Context, username string) (*data.Developer, error)

func (*Store) GetDeveloperPercentages

func (s *Store) GetDeveloperPercentages(ctx context.Context, entity, org, repo *string, ex []string, months int) ([]*data.CountedItem, error)

func (*Store) GetDeveloperUsernames

func (s *Store) GetDeveloperUsernames(ctx context.Context) ([]string, error)

func (*Store) GetEntity

func (s *Store) GetEntity(ctx context.Context, val string) (*data.EntityResult, error)

func (*Store) GetEntityLike

func (s *Store) GetEntityLike(ctx context.Context, query string, limit int) ([]*data.ListItem, error)

func (*Store) GetEntityPercentages

func (s *Store) GetEntityPercentages(ctx context.Context, entity, org, repo *string, ex []string, months int) ([]*data.CountedItem, error)

func (*Store) GetEventTypeSeries

func (s *Store) GetEventTypeSeries(ctx context.Context, org, repo, entity *string, months int) (*data.EventTypeSeries, error)

func (*Store) GetForksAndActivity

func (s *Store) GetForksAndActivity(ctx context.Context, org, repo, entity *string, months int) (*data.ForksAndActivitySeries, error)

func (*Store) GetInsightsSummary

func (s *Store) GetInsightsSummary(ctx context.Context, org, repo, entity *string, months int) (*data.InsightsSummary, error)

func (*Store) GetIssueOpenCloseRatio

func (s *Store) GetIssueOpenCloseRatio(ctx context.Context, org, repo, entity *string, months int) (*data.IssueRatioSeries, error)

func (*Store) GetMinEventDate

func (s *Store) GetMinEventDate(ctx context.Context, org, repo *string) (string, error)

func (*Store) GetNoFullnameDeveloperUsernames

func (s *Store) GetNoFullnameDeveloperUsernames(ctx context.Context) ([]string, error)

func (*Store) GetOrComputeDeepReputation

func (s *Store) GetOrComputeDeepReputation(ctx context.Context, token, username string) (*data.UserReputation, error)

func (*Store) GetOrgLike

func (s *Store) GetOrgLike(ctx context.Context, query string, limit int) ([]*data.ListItem, error)

func (*Store) GetPRReviewRatio

func (s *Store) GetPRReviewRatio(ctx context.Context, org, repo, entity *string, months int) (*data.PRReviewRatioSeries, error)

func (*Store) GetPRSizeDistribution

func (s *Store) GetPRSizeDistribution(ctx context.Context, org, repo, entity *string, months int) (*data.PRSizeSeries, error)

func (*Store) GetReleaseCadence

func (s *Store) GetReleaseCadence(ctx context.Context, org, repo, entity *string, months int) (*data.ReleaseCadenceSeries, error)

func (*Store) GetReleaseDownloads

func (s *Store) GetReleaseDownloads(ctx context.Context, org, repo *string, months int) (*data.ReleaseDownloadsSeries, error)

func (*Store) GetReleaseDownloadsByTag

func (s *Store) GetReleaseDownloadsByTag(ctx context.Context, org, repo *string, months int) (*data.ReleaseDownloadsByTagSeries, error)

func (*Store) GetRepoInsights

func (s *Store) GetRepoInsights(ctx context.Context, org, repo *string) ([]*data.RepoInsights, error)

func (*Store) GetRepoInsightsGeneratedAt

func (s *Store) GetRepoInsightsGeneratedAt(ctx context.Context, org, repo string) (string, error)

func (*Store) GetRepoLike

func (s *Store) GetRepoLike(ctx context.Context, query string, limit int) ([]*data.ListItem, error)

func (*Store) GetRepoMetas

func (s *Store) GetRepoMetas(ctx context.Context, org, repo *string) ([]*data.RepoMeta, error)

func (*Store) GetRepoMetricHistory

func (s *Store) GetRepoMetricHistory(ctx context.Context, org, repo *string, months int) ([]*data.RepoMetricHistory, error)

func (*Store) GetRepoOverview

func (s *Store) GetRepoOverview(ctx context.Context, org *string, months int) ([]*data.RepoOverview, error)

func (*Store) GetReputationDistribution

func (s *Store) GetReputationDistribution(ctx context.Context, org, repo, entity *string, months int) (*data.ReputationDistribution, error)

func (*Store) GetReviewLatency

func (s *Store) GetReviewLatency(ctx context.Context, org, repo, entity *string, months int) (*data.ReviewLatencySeries, error)

func (*Store) GetState

func (s *Store) GetState(ctx context.Context, query, org, repo string, min time.Time) (*data.State, error)

func (*Store) GetTimeToClose

func (s *Store) GetTimeToClose(ctx context.Context, org, repo, entity *string, months int) (*data.VelocitySeries, error)

func (*Store) GetTimeToFirstResponse

func (s *Store) GetTimeToFirstResponse(ctx context.Context, org, repo, entity *string, months int) (*data.FirstResponseSeries, error)

func (*Store) GetTimeToMerge

func (s *Store) GetTimeToMerge(ctx context.Context, org, repo, entity *string, months int) (*data.VelocitySeries, error)

func (*Store) GetTimeToRestoreBugs

func (s *Store) GetTimeToRestoreBugs(ctx context.Context, org, repo, entity *string, months int) (*data.VelocitySeries, error)

func (*Store) ImportAllContainerVersions

func (s *Store) ImportAllContainerVersions(ctx context.Context, token string) error

func (*Store) ImportAllReleases

func (s *Store) ImportAllReleases(ctx context.Context, token string) error

func (*Store) ImportAllRepoMeta

func (s *Store) ImportAllRepoMeta(ctx context.Context, token string) error

func (*Store) ImportAllRepoMetricHistory

func (s *Store) ImportAllRepoMetricHistory(ctx context.Context, token string) error

func (*Store) ImportContainerVersions

func (s *Store) ImportContainerVersions(ctx context.Context, token, org, repo string) error

func (*Store) ImportDeepReputation

func (s *Store) ImportDeepReputation(ctx context.Context, tokenFn data.TokenFunc, limit, staleHours int, org, repo *string) (*data.DeepReputationResult, error)

func (*Store) ImportEvents

func (s *Store) ImportEvents(ctx context.Context, token, owner, repo string, months int) (map[string]int, *data.ImportSummary, error)

func (*Store) ImportReleases

func (s *Store) ImportReleases(ctx context.Context, token, owner, repo string) error

func (*Store) ImportRepoMeta

func (s *Store) ImportRepoMeta(ctx context.Context, token, owner, repo string) error

func (*Store) ImportRepoMetricHistory

func (s *Store) ImportRepoMetricHistory(ctx context.Context, token, owner, repo string) error

func (*Store) ImportReputation

func (s *Store) ImportReputation(ctx context.Context, org, repo *string) (*data.ReputationResult, error)

func (*Store) MergeDeveloper

func (s *Store) MergeDeveloper(ctx context.Context, client *http.Client, username string, cDev *data.CNCFDeveloper) (*data.Developer, error)

func (*Store) QueryEntities

func (s *Store) QueryEntities(ctx context.Context, val string, limit int) ([]*data.CountedItem, error)

func (*Store) SaveAndApplyDeveloperSub

func (s *Store) SaveAndApplyDeveloperSub(ctx context.Context, prop, old, new string) (*data.Substitution, error)

func (*Store) SaveDevelopers

func (s *Store) SaveDevelopers(ctx context.Context, devs []*data.Developer) error

func (*Store) SaveRepoInsights

func (s *Store) SaveRepoInsights(ctx context.Context, org, repo string, ri *data.RepoInsights) error

func (*Store) SaveState

func (s *Store) SaveState(ctx context.Context, query, org, repo string, state *data.State) error

func (*Store) SearchDeveloperUsernames

func (s *Store) SearchDeveloperUsernames(ctx context.Context, query string, org, repo *string, months, limit int) ([]string, error)

func (*Store) SearchDevelopers

func (s *Store) SearchDevelopers(ctx context.Context, val string, limit int) ([]*data.DeveloperListItem, error)

func (*Store) SearchEvents

func (s *Store) SearchEvents(ctx context.Context, q *data.EventSearchCriteria) ([]*data.EventDetails, error)

func (*Store) UpdateDeveloperNames

func (s *Store) UpdateDeveloperNames(ctx context.Context, devs map[string]string) error

func (*Store) UpdateEvents

func (s *Store) UpdateEvents(ctx context.Context, token string, concurrency int) (map[string]int, error)

Jump to

Keyboard shortcuts

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