Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: limit the scope of the template average build time query to the last 100#19648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
cstyan merged 2 commits intomainfromcallum/template-build-time-query
Sep 1, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletioncoderd/database/dbauthz/dbauthz.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2792,7 +2792,7 @@ func (q *querier) GetTemplateAppInsightsByTemplate(ctx context.Context, arg data
}

// Only used by metrics cache.
func (q*querier)GetTemplateAverageBuildTime(ctx context.Context,argdatabase.GetTemplateAverageBuildTimeParams) (database.GetTemplateAverageBuildTimeRow,error) {
func (q*querier)GetTemplateAverageBuildTime(ctx context.Context,arguuid.NullUUID) (database.GetTemplateAverageBuildTimeRow,error) {
iferr:=q.authorizeContext(ctx,policy.ActionRead,rbac.ResourceSystem);err!=nil {
return database.GetTemplateAverageBuildTimeRow{},err
}
Expand Down
2 changes: 1 addition & 1 deletioncoderd/database/dbauthz/dbauthz_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3160,7 +3160,7 @@ func (s *MethodTestSuite) TestSystemFunctions() {
check.Args(arg).Asserts(rbac.ResourceSystem,policy.ActionRead).Returns(p)
}))
s.Run("GetTemplateAverageBuildTime",s.Mocked(func(dbm*dbmock.MockStore,_*gofakeit.Faker,check*expects) {
arg:=database.GetTemplateAverageBuildTimeParams{}
arg:=uuid.NullUUID{}
dbm.EXPECT().GetTemplateAverageBuildTime(gomock.Any(),arg).Return(database.GetTemplateAverageBuildTimeRow{},nil).AnyTimes()
check.Args(arg).Asserts(rbac.ResourceSystem,policy.ActionRead)
}))
Expand Down
2 changes: 1 addition & 1 deletioncoderd/database/dbmetrics/querymetrics.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

8 changes: 4 additions & 4 deletionscoderd/database/dbmock/dbmock.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

2 changes: 1 addition & 1 deletioncoderd/database/querier.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

11 changes: 3 additions & 8 deletionscoderd/database/queries.sql.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

2 changes: 1 addition & 1 deletioncoderd/database/queries/templates.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -203,11 +203,11 @@ JOIN provisioner_jobs pj ON
WHERE
template_versions.template_id = @template_id AND
(pj.completed_at IS NOT NULL) AND (pj.started_at IS NOT NULL) AND
(pj.started_at > @start_time) AND
(pj.canceled_at IS NULL) AND
((pj.error IS NULL) OR (pj.error = ''))
ORDER BY
workspace_builds.created_at DESC
LIMIT 100
)
SELECT
-- Postgres offers no clear way to DRY this short of a function or other
Expand Down
10 changes: 3 additions & 7 deletionscoderd/metricscache/metricscache.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -101,16 +101,12 @@ func (c *Cache) refreshTemplateBuildTimes(ctx context.Context) error {
for _, template := range templates {
ids = append(ids, template.ID)

templateAvgBuildTime, err := c.database.GetTemplateAverageBuildTime(ctx, database.GetTemplateAverageBuildTimeParams{
TemplateID:uuid.NullUUID{
templateAvgBuildTime, err := c.database.GetTemplateAverageBuildTime(ctx,
uuid.NullUUID{
UUID: template.ID,
Valid: true,
},
StartTime: sql.NullTime{
Time: dbtime.Time(c.clock.Now().AddDate(0, 0, -30)),
Valid: true,
},
})
)
if err != nil {
return err
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp