diff --git a/enterprise/internal/insights/compression/worker.go b/enterprise/internal/insights/compression/worker.go index 48b59e07508..fc738533240 100644 --- a/enterprise/internal/insights/compression/worker.go +++ b/enterprise/internal/insights/compression/worker.go @@ -9,6 +9,7 @@ import ( "github.com/cockroachdb/errors" + "github.com/sourcegraph/sourcegraph/internal/conf" "github.com/sourcegraph/sourcegraph/internal/observation" "github.com/sourcegraph/sourcegraph/internal/types" @@ -84,8 +85,11 @@ func NewCommitIndexerWorker(ctx context.Context, base dbutil.DB, insights dbutil } func (i *CommitIndexer) Handler(ctx context.Context, observationContext *observation.Context) goroutine.BackgroundRoutine { - //TODO(insights) consider adding setting for index interval - interval := time.Hour * 1 + intervalMinutes := conf.Get().InsightsCommitIndexerInterval + if intervalMinutes <= 0 { + intervalMinutes = 60 + } + interval := time.Minute * time.Duration(intervalMinutes) return goroutine.NewPeriodicGoroutineWithMetrics(ctx, interval, goroutine.NewHandlerWithErrorMessage("commit_indexer_handler", func(ctx context.Context) error { diff --git a/internal/conf/parse.go b/internal/conf/parse.go index c4227720f27..9c9a6f4a794 100644 --- a/internal/conf/parse.go +++ b/internal/conf/parse.go @@ -58,6 +58,7 @@ var requireRestart = []string{ "externalURL", "update.channel", "insights.query.worker.concurrency", + "insights.commit.indexer.interval", } // NeedRestartToApply determines if a restart is needed to apply the changes diff --git a/schema/schema.go b/schema/schema.go index 16a928c8039..3521763647e 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -1536,6 +1536,8 @@ type SiteConfiguration struct { HtmlHeadBottom string `json:"htmlHeadBottom,omitempty"` // HtmlHeadTop description: HTML to inject at the top of the `` element on each page, for analytics scripts HtmlHeadTop string `json:"htmlHeadTop,omitempty"` + // InsightsCommitIndexerInterval description: The interval (in minutes) at which the insights commit indexer will check for new commits. + InsightsCommitIndexerInterval int `json:"insights.commit.indexer.interval,omitempty"` // InsightsHistoricalFrameLength description: (debug) duration of historical insights timeframes, one point per repository will be recorded in each timeframe. InsightsHistoricalFrameLength string `json:"insights.historical.frameLength,omitempty"` // InsightsHistoricalFrames description: (debug) number of historical insights timeframes to populate diff --git a/schema/site.schema.json b/schema/site.schema.json index 5d6fe3c2f82..d0ae54194d9 100644 --- a/schema/site.schema.json +++ b/schema/site.schema.json @@ -908,6 +908,13 @@ "examples": [50.0, 0.5], "!go": { "pointer": true } }, + "insights.commit.indexer.interval": { + "description": "The interval (in minutes) at which the insights commit indexer will check for new commits.", + "type": "integer", + "group": "CodeInsights", + "default": 60, + "examples": [120] + }, "htmlHeadTop": { "description": "HTML to inject at the top of the `` element on each page, for analytics scripts", "type": "string",