Documentation
¶
Index ¶
- Variables
- func GroupExpr(g Granularity, col string) string
- func MomentumFormat(g Granularity) string
- func MomentumInterval(g Granularity) string
- func RunSaaSMigrations(db *sql.DB) error
- func TrendWindow(g Granularity) int
- type DBTX
- type Granularity
- type PoolConfig
- type Store
- func (s *Store) ApplySubstitutions(ctx context.Context) ([]*data.Substitution, error)
- func (s *Store) CleanEntities(ctx context.Context) error
- func (s *Store) ClearState(ctx context.Context, org, repo string) error
- func (s *Store) Close() error
- func (s *Store) DB() *sql.DB
- func (s *Store) DeleteRepoData(ctx context.Context, org, repo string) (*data.DeleteResult, error)
- func (s *Store) EnrichDeveloperEntities(ctx context.Context, token string) error
- func (s *Store) GetAgingPRs(ctx context.Context, org, repo, entity *string, days int) (*data.AgingPRsSeries, error)
- func (s *Store) GetAllOrgRepos(ctx context.Context) ([]*data.OrgRepoItem, error)
- func (s *Store) GetBackfillUntil(ctx context.Context, org, repo string) (*time.Time, error)
- func (s *Store) GetChangeFailureRate(ctx context.Context, org, repo, entity *string, days int) (*data.ChangeFailureRateSeries, error)
- func (s *Store) GetContainerActivity(ctx context.Context, org, repo *string, days int) (*data.ContainerActivitySeries, error)
- func (s *Store) GetContributorComposition(ctx context.Context, org, repo, entity *string, days int) (*data.ContributorComposition, error)
- func (s *Store) GetContributorFunnel(ctx context.Context, org, repo, entity *string, days int) (*data.ContributorFunnelSeries, error)
- func (s *Store) GetContributorMomentum(ctx context.Context, org, repo, entity *string, days int) (*data.MomentumSeries, error)
- func (s *Store) GetContributorProfile(ctx context.Context, username string, org, repo, entity *string, days int) (*data.ContributorProfileSeries, error)
- func (s *Store) GetContributorRetention(ctx context.Context, org, repo, entity *string, days int) (*data.RetentionSeries, error)
- func (s *Store) GetDailyActivity(ctx context.Context, org, repo, entity *string, days int) (*data.DailyActivitySeries, error)
- func (s *Store) GetDataState(ctx context.Context) (map[string]int64, error)
- func (s *Store) GetDeveloper(ctx context.Context, username string) (*data.Developer, error)
- func (s *Store) GetDeveloperPercentages(ctx context.Context, entity, org, repo *string, ex []string, days int) ([]*data.CountedItem, error)
- func (s *Store) GetDeveloperUsernames(ctx context.Context) ([]string, error)
- func (s *Store) GetEntity(ctx context.Context, val string) (*data.EntityResult, error)
- func (s *Store) GetEntityLike(ctx context.Context, query string, limit int) ([]*data.ListItem, error)
- func (s *Store) GetEntityPercentages(ctx context.Context, entity, org, repo *string, ex []string, days int) ([]*data.CountedItem, error)
- func (s *Store) GetEventTypeSeries(ctx context.Context, org, repo, entity *string, days int) (*data.EventTypeSeries, error)
- func (s *Store) GetForksAndActivity(ctx context.Context, org, repo, entity *string, days int) (*data.ForksAndActivitySeries, error)
- func (s *Store) GetInsightsSummary(ctx context.Context, org, repo, entity *string, days int) (*data.InsightsSummary, error)
- func (s *Store) GetIssueOpenCloseRatio(ctx context.Context, org, repo, entity *string, days int) (*data.IssueRatioSeries, error)
- func (s *Store) GetMaxEventTime(ctx context.Context, org, repo string) (time.Time, error)
- func (s *Store) GetMinEventDate(ctx context.Context, org, repo *string) (string, error)
- func (s *Store) GetNoFullnameDeveloperUsernames(ctx context.Context) ([]string, error)
- func (s *Store) GetOrgLike(ctx context.Context, query string, limit int) ([]*data.ListItem, error)
- func (s *Store) GetPRReviewRatio(ctx context.Context, org, repo, entity *string, days int) (*data.PRReviewRatioSeries, error)
- func (s *Store) GetPRSizeDistribution(ctx context.Context, org, repo, entity *string, days int) (*data.PRSizeSeries, error)
- func (s *Store) GetPortfolioSummary(ctx context.Context, org, repo *string, days int) (*data.PortfolioSummary, error)
- func (s *Store) GetReleaseCadence(ctx context.Context, org, repo, entity *string, days int) (*data.ReleaseCadenceSeries, error)
- func (s *Store) GetReleaseDownloads(ctx context.Context, org, repo *string, days int) (*data.ReleaseDownloadsSeries, error)
- func (s *Store) GetReleaseDownloadsByTag(ctx context.Context, org, repo *string, days int) (*data.ReleaseDownloadsByTagSeries, error)
- func (s *Store) GetRepoInsights(ctx context.Context, org, repo *string) ([]*data.RepoInsights, error)
- func (s *Store) GetRepoInsightsEventCount(ctx context.Context, org, repo string) (int, error)
- func (s *Store) GetRepoInsightsGeneratedAt(ctx context.Context, org, repo string) (string, error)
- func (s *Store) GetRepoLike(ctx context.Context, query string, limit int) ([]*data.ListItem, error)
- func (s *Store) GetRepoMetas(ctx context.Context, org, repo *string) ([]*data.RepoMeta, error)
- func (s *Store) GetRepoMetricHistory(ctx context.Context, org, repo *string, days int) ([]*data.RepoMetricHistory, error)
- func (s *Store) GetRepoOverview(ctx context.Context, org *string, days int) ([]*data.RepoOverview, error)
- func (s *Store) GetResponseSLO(ctx context.Context, org, repo, entity *string, days int) (*data.ResponseSLOSeries, error)
- func (s *Store) GetReviewLatency(ctx context.Context, org, repo, entity *string, days int) (*data.ReviewLatencySeries, error)
- func (s *Store) GetSignals(ctx context.Context, org *string, limit int) ([]*data.Signal, error)
- func (s *Store) GetState(ctx context.Context, query, org, repo string, min time.Time) (*data.State, error)
- func (s *Store) GetTimeToClose(ctx context.Context, org, repo, entity *string, days int) (*data.VelocitySeries, error)
- func (s *Store) GetTimeToFirstResponse(ctx context.Context, org, repo, entity *string, days int) (*data.FirstResponseSeries, error)
- func (s *Store) GetTimeToMerge(ctx context.Context, org, repo, entity *string, days int) (*data.VelocitySeries, error)
- func (s *Store) GetTimeToRestoreBugs(ctx context.Context, org, repo, entity *string, days int) (*data.VelocitySeries, error)
- func (s *Store) GetUnansweredRate(ctx context.Context, org, repo, entity *string, days int) (*data.UnansweredSeries, error)
- func (s *Store) GetUnenrichedDeveloperUsernames(ctx context.Context) ([]string, error)
- func (s *Store) HasForkEvents(ctx context.Context, org, repo string) (bool, error)
- func (s *Store) HasState(ctx context.Context, org, repo string) (bool, error)
- func (s *Store) ImportAllContainerVersions(ctx context.Context, token string) error
- func (s *Store) ImportAllReleases(ctx context.Context, token string) error
- func (s *Store) ImportAllRepoMeta(ctx context.Context, token string) error
- func (s *Store) ImportAllRepoMetricHistory(ctx context.Context, token string) error
- func (s *Store) ImportContainerVersions(ctx context.Context, token, org, repo string) error
- func (s *Store) ImportEvents(ctx context.Context, tokenFn data.TokenFunc, exhaustFn data.ExhaustFunc, ...) (map[string]int, *data.ImportSummary, error)
- func (s *Store) ImportReleases(ctx context.Context, token, owner, repo string) error
- func (s *Store) ImportRepoMeta(ctx context.Context, token, owner, repo string) (time.Time, error)
- func (s *Store) ImportRepoMetricHistory(ctx context.Context, token, owner, repo string) error
- func (s *Store) ImportReputation(ctx context.Context, org, repo *string) (*data.ReputationResult, error)
- func (s *Store) QueryEntities(ctx context.Context, val string, limit int) ([]*data.CountedItem, error)
- func (s *Store) SaveAndApplyDeveloperSub(ctx context.Context, prop, old, new string) (*data.Substitution, error)
- func (s *Store) SaveBackfillUntil(ctx context.Context, org, repo string, until time.Time) error
- func (s *Store) SaveDevelopers(ctx context.Context, devs []*data.Developer) error
- func (s *Store) SaveRepoInsights(ctx context.Context, org, repo string, ri *data.RepoInsights) error
- func (s *Store) SaveState(ctx context.Context, query, org, repo string, state *data.State) error
- func (s *Store) SearchDeveloperUsernames(ctx context.Context, query string, org, repo *string, days, limit int) ([]string, error)
- func (s *Store) SearchDevelopers(ctx context.Context, val string, limit int) ([]*data.DeveloperListItem, error)
- func (s *Store) SearchEvents(ctx context.Context, q *data.EventSearchCriteria) ([]*data.EventDetails, error)
- func (s *Store) UpdateDeveloperNames(ctx context.Context, devs map[string]string) error
- func (s *Store) UpdateEvents(ctx context.Context, token string, concurrency int) (map[string]int, error)
Constants ¶
This section is empty.
Variables ¶
var EventTypes = []string{ data.EventTypePR, data.EventTypeIssue, data.EventTypeIssueComment, data.EventTypePRReview, data.EventTypeFork, }
Functions ¶
func GroupExpr ¶ added in v0.24.0
func GroupExpr(g Granularity, col string) string
GroupExpr returns the SQL expression that buckets a column by granularity.
- GranMonth: "TO_CHAR(col::date, 'YYYY-MM')" → "2024-03"
- GranWeek: "TO_CHAR(date_trunc(...))" → "2024-03-04" (Monday)
Both branches cast to date first so the expression works against DATE, TIMESTAMPTZ, and text columns alike.
func MomentumFormat ¶ added in v0.24.0
func MomentumFormat(g Granularity) string
MomentumFormat returns the TO_CHAR format for momentum date comparison.
func MomentumInterval ¶ added in v0.24.0
func MomentumInterval(g Granularity) string
MomentumInterval returns the SQL interval for the rolling momentum window.
func RunSaaSMigrations ¶
RunSaaSMigrations runs SaaS-specific migrations (tenant tables, RLS policies). Called by devpulse-cloud only, not the self-hosted CLI.
func TrendWindow ¶ added in v0.24.0
func TrendWindow(g Granularity) int
TrendWindow returns the number of data points for the moving average.
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 Granularity ¶ added in v0.24.0
type Granularity string
Granularity controls how time-series data is bucketed.
const ( GranWeek Granularity = "week" GranMonth Granularity = "month" )
func AutoGranularity ¶ added in v0.24.0
func AutoGranularity(days int) Granularity
AutoGranularity selects weekly or monthly grouping based on the time window.
type PoolConfig ¶ added in v0.12.3
type PoolConfig struct {
AppName string
MaxOpenConns int
MaxIdleConns int
ConnMaxLifetime time.Duration
ConnMaxIdleTime time.Duration
}
PoolConfig controls database connection pool sizing.
func DefaultPoolConfig ¶ added in v0.12.3
func DefaultPoolConfig() PoolConfig
DefaultPoolConfig returns pool settings suitable for the site service.
func ImportPoolConfig ¶ added in v0.12.3
func ImportPoolConfig() PoolConfig
ImportPoolConfig returns smaller pool settings suitable for batch import workers.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements data.Store for PostgreSQL.
func New ¶
func New(dsn string, cfgs ...PoolConfig) (*Store, error)
New creates a new PostgreSQL Store, running migrations automatically. Uses DefaultPoolConfig if no config is provided. DB_MAX_OPEN_CONNS and DB_MAX_IDLE_CONNS env vars override code defaults.
func NewFromConn ¶
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(cfgs ...PoolConfig) (*Store, error)
NewFromEnv creates a Store from DATABASE_URL env var, runs base + SaaS migrations. Uses DefaultPoolConfig if no config is provided.
func (*Store) ApplySubstitutions ¶
func (*Store) DeleteRepoData ¶
func (*Store) EnrichDeveloperEntities ¶ added in v0.8.1
EnrichDeveloperEntities fetches full GitHub profiles for developers whose entity is NULL (never enriched) and writes entity back. Developers with no GitHub company get entity=” which marks them as enriched so they are not re-fetched next run.
Updates are batched into transactions of developerEnrichmentChunk rows so the per-row round-trip overhead is amortized and a transient failure does not invalidate progress made by earlier chunks.
func (*Store) GetAgingPRs ¶ added in v0.15.0
func (*Store) GetAllOrgRepos ¶
func (*Store) GetBackfillUntil ¶ added in v0.46.0
func (*Store) GetChangeFailureRate ¶
func (*Store) GetContainerActivity ¶
func (*Store) GetContributorComposition ¶ added in v0.47.0
func (*Store) GetContributorFunnel ¶
func (*Store) GetContributorMomentum ¶
func (*Store) GetContributorProfile ¶
func (*Store) GetContributorRetention ¶
func (*Store) GetDailyActivity ¶
func (*Store) GetDataState ¶
func (*Store) GetDeveloper ¶
func (*Store) GetDeveloperPercentages ¶
func (*Store) GetDeveloperUsernames ¶
func (*Store) GetEntityLike ¶
func (*Store) GetEntityPercentages ¶
func (*Store) GetEventTypeSeries ¶
func (*Store) GetForksAndActivity ¶
func (*Store) GetInsightsSummary ¶
func (*Store) GetIssueOpenCloseRatio ¶
func (*Store) GetMaxEventTime ¶ added in v0.38.0
func (*Store) GetMinEventDate ¶
func (*Store) GetNoFullnameDeveloperUsernames ¶
func (*Store) GetOrgLike ¶
func (*Store) GetPRReviewRatio ¶
func (*Store) GetPRSizeDistribution ¶
func (*Store) GetPortfolioSummary ¶ added in v0.15.0
func (*Store) GetReleaseCadence ¶
func (*Store) GetReleaseDownloads ¶
func (*Store) GetReleaseDownloadsByTag ¶
func (*Store) GetRepoInsights ¶
func (*Store) GetRepoInsightsEventCount ¶ added in v0.16.3
func (*Store) GetRepoInsightsGeneratedAt ¶
func (*Store) GetRepoLike ¶
func (*Store) GetRepoMetas ¶
func (*Store) GetRepoMetricHistory ¶
func (*Store) GetRepoOverview ¶
func (*Store) GetResponseSLO ¶ added in v0.15.0
func (*Store) GetReviewLatency ¶
func (*Store) GetSignals ¶ added in v0.15.0
func (*Store) GetTimeToClose ¶
func (*Store) GetTimeToFirstResponse ¶
func (*Store) GetTimeToMerge ¶
func (*Store) GetTimeToRestoreBugs ¶
func (*Store) GetUnansweredRate ¶ added in v0.15.0
func (*Store) GetUnenrichedDeveloperUsernames ¶ added in v0.8.1
func (*Store) HasForkEvents ¶ added in v0.51.54
HasForkEvents reports whether the events table contains at least one fork row for the repo. Used by the import skip-check so a repo whose fork data is missing (e.g. just after the migration-025 wipe) gets re-imported even when pushed_at hasn't moved.
func (*Store) ImportAllContainerVersions ¶
func (*Store) ImportAllReleases ¶
func (*Store) ImportAllRepoMeta ¶
func (*Store) ImportAllRepoMetricHistory ¶
func (*Store) ImportContainerVersions ¶
func (*Store) ImportEvents ¶
func (*Store) ImportReleases ¶
func (*Store) ImportRepoMeta ¶
func (*Store) ImportRepoMetricHistory ¶
func (*Store) ImportReputation ¶
func (*Store) QueryEntities ¶
func (*Store) SaveAndApplyDeveloperSub ¶
func (*Store) SaveBackfillUntil ¶ added in v0.46.0
func (*Store) SaveDevelopers ¶
func (*Store) SaveRepoInsights ¶
func (*Store) SearchDeveloperUsernames ¶
func (*Store) SearchDevelopers ¶
func (*Store) SearchEvents ¶
func (s *Store) SearchEvents(ctx context.Context, q *data.EventSearchCriteria) ([]*data.EventDetails, error)