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

Commit0f51f35

Browse files
committed
added queries for fetching NotStartedProvisionerJobs
1 parent8f64d49 commit0f51f35

File tree

7 files changed

+108
-0
lines changed

7 files changed

+108
-0
lines changed

‎coderd/database/dbauthz/dbauthz.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,6 +1992,10 @@ func (q *querier) GetLogoURL(ctx context.Context) (string, error) {
19921992
returnq.db.GetLogoURL(ctx)
19931993
}
19941994

1995+
func (q*querier)GetNotStartedProvisionerJobs(ctx context.Context,notStartedSince time.Time) ([]database.ProvisionerJob,error) {
1996+
returnq.db.GetNotStartedProvisionerJobs(ctx,notStartedSince)
1997+
}
1998+
19951999
func (q*querier)GetNotificationMessagesByStatus(ctx context.Context,arg database.GetNotificationMessagesByStatusParams) ([]database.NotificationMessage,error) {
19962000
iferr:=q.authorizeContext(ctx,policy.ActionRead,rbac.ResourceNotificationMessage);err!=nil {
19972001
returnnil,err

‎coderd/database/dbmem/dbmem.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3897,6 +3897,23 @@ func (q *FakeQuerier) GetLogoURL(_ context.Context) (string, error) {
38973897
returnq.logoURL,nil
38983898
}
38993899

3900+
func (q*FakeQuerier)GetNotStartedProvisionerJobs(ctx context.Context,notStartedSince time.Time) ([]database.ProvisionerJob,error) {
3901+
q.mutex.RLock()
3902+
deferq.mutex.RUnlock()
3903+
3904+
notStartedJobs:= []database.ProvisionerJob{}
3905+
for_,provisionerJob:=rangeq.provisionerJobs {
3906+
if!provisionerJob.StartedAt.Valid&&!provisionerJob.CompletedAt.Valid&&provisionerJob.UpdatedAt.Before(notStartedSince) {
3907+
// clone the Tags before appending, since maps are reference types and
3908+
// we don't want the caller to be able to mutate the map we have inside
3909+
// dbmem!
3910+
provisionerJob.Tags=maps.Clone(provisionerJob.Tags)
3911+
notStartedJobs=append(notStartedJobs,provisionerJob)
3912+
}
3913+
}
3914+
returnnotStartedJobs,nil
3915+
}
3916+
39003917
func (q*FakeQuerier)GetNotificationMessagesByStatus(_ context.Context,arg database.GetNotificationMessagesByStatusParams) ([]database.NotificationMessage,error) {
39013918
err:=validateDatabaseType(arg)
39023919
iferr!=nil {

‎coderd/database/dbmetrics/querymetrics.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/dbmock/dbmock.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/querier.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries.sql.go

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/provisionerjobs.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@ WHERE
266266
AND started_atIS NOT NULL
267267
AND completed_at ISNULL;
268268

269+
-- name: GetNotStartedProvisionerJobs :many
270+
SELECT
271+
*
272+
FROM
273+
provisioner_jobs
274+
WHERE
275+
updated_at< $1
276+
AND started_at ISNULL
277+
AND completed_at ISNULL;
278+
269279
-- name: InsertProvisionerJobTimings :many
270280
INSERT INTO provisioner_job_timings (job_id, started_at, ended_at, stage, source, action, resource)
271281
SELECT

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp