Skip to content

chore: add workspace_build_deadlines view #13286

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
change view to workspaces
  • Loading branch information
f0ssel committed May 16, 2024
commit 02c9991ed3b4e6708a677cdfde5d20b5ed09d388
75 changes: 39 additions & 36 deletions coderd/database/dump.sql

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

28 changes: 17 additions & 11 deletions coderd/database/migrations/000209_workspace_deadline_view.up.sql
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
CREATE VIEW workspace_build_deadlines AS
CREATE VIEW workspace_deadlines AS
SELECT
workspace_builds.id,
COALESCE(
LEAST(
workspaces.last_used_at + (workspaces.ttl / 1000 / 1000 / 1000 || ' seconds')::interval,
workspace_builds.max_deadline
),
'0001-01-01 00:00:00+00'::timestamp with time zone
workspaces.id,
LEAST(
workspaces.last_used_at + (workspaces.ttl / 1000 / 1000 / 1000 || ' seconds')::interval,
workspace_builds.max_deadline
) AS deadline
FROM
workspace_builds
workspaces
LEFT JOIN
workspaces
workspace_builds
ON
workspace_builds.workspace_id = workspaces.id;
workspace_builds.workspace_id = workspaces.id
WHERE
workspace_builds.build_number = (
SELECT
MAX(build_number)
FROM
workspace_builds
WHERE
workspace_builds.workspace_id = workspaces.id
);
10 changes: 5 additions & 5 deletions coderd/database/models.go

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

2 changes: 1 addition & 1 deletion coderd/database/sqlc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ sql:
- column: "template_usage_stats.app_usage_mins"
go_type:
type: "StringMapOfInt"
- column: "workspace_build_deadlines.deadline"
- column: "workspace_deadlines.deadline"
go_type:
type: "time.Time"
rename:
Expand Down
Loading