- Notifications
You must be signed in to change notification settings - Fork1.1k
feat: add display name field for tasks#20856
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
9ecbe6239d380569b2e9dac0a1f975277dc28023b74a6db77b5176c64f878bd40c5ef344e6868144e196da340dd7e4f048ab81b40File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| -- Drop view first before removing the display_name column from tasks | ||
| DROP VIEW IF EXISTS tasks_with_status; | ||
| -- Remove display_name column from tasks | ||
| ALTER TABLE tasks DROP COLUMN display_name; | ||
| -- Recreate view without the display_name column. | ||
| -- This restores the view to its previous state after removing display_name from tasks. | ||
| CREATE VIEW | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It seems adding the view recreation is required on both migrations, because otherwise sqlc would not generate the Task structure with Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Unfortunately this is the way ™️ Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. We need to get this implemented in our sqlc fork:Emyrk/sqlc#1 | ||
| tasks_with_status | ||
| AS | ||
| SELECT | ||
| tasks.*, | ||
| CASE | ||
| WHEN tasks.workspace_id IS NULL OR latest_build.job_status IS NULL THEN 'pending'::task_status | ||
| WHEN latest_build.job_status = 'failed' THEN 'error'::task_status | ||
| WHEN latest_build.transition IN ('stop', 'delete') | ||
| AND latest_build.job_status = 'succeeded' THEN 'paused'::task_status | ||
| WHEN latest_build.transition = 'start' | ||
| AND latest_build.job_status = 'pending' THEN 'initializing'::task_status | ||
| WHEN latest_build.transition = 'start' AND latest_build.job_status IN ('running', 'succeeded') THEN | ||
| CASE | ||
| WHEN agent_status.none THEN 'initializing'::task_status | ||
| WHEN agent_status.connecting THEN 'initializing'::task_status | ||
| WHEN agent_status.connected THEN | ||
| CASE | ||
| WHEN app_status.any_unhealthy THEN 'error'::task_status | ||
| WHEN app_status.any_initializing THEN 'initializing'::task_status | ||
| WHEN app_status.all_healthy_or_disabled THEN 'active'::task_status | ||
| ELSE 'unknown'::task_status | ||
| END | ||
| ELSE 'unknown'::task_status | ||
| END | ||
| ELSE 'unknown'::task_status | ||
| END AS status, | ||
| task_app.*, | ||
| task_owner.* | ||
| FROM | ||
| tasks | ||
| CROSS JOIN LATERAL ( | ||
| SELECT | ||
| vu.username AS owner_username, | ||
| vu.name AS owner_name, | ||
| vu.avatar_url AS owner_avatar_url | ||
| FROM visible_users vu | ||
| WHERE vu.id = tasks.owner_id | ||
| ) task_owner | ||
| LEFT JOIN LATERAL ( | ||
| SELECT workspace_build_number, workspace_agent_id, workspace_app_id | ||
| FROM task_workspace_apps task_app | ||
| WHERE task_id = tasks.id | ||
| ORDER BY workspace_build_number DESC | ||
| LIMIT 1 | ||
| ) task_app ON TRUE | ||
| LEFT JOIN LATERAL ( | ||
| SELECT | ||
| workspace_build.transition, | ||
| provisioner_job.job_status, | ||
| workspace_build.job_id | ||
| FROM workspace_builds workspace_build | ||
| JOIN provisioner_jobs provisioner_job ON provisioner_job.id = workspace_build.job_id | ||
| WHERE workspace_build.workspace_id = tasks.workspace_id | ||
| AND workspace_build.build_number = task_app.workspace_build_number | ||
| ) latest_build ON TRUE | ||
| CROSS JOIN LATERAL ( | ||
| SELECT | ||
| COUNT(*) = 0 AS none, | ||
| bool_or(workspace_agent.lifecycle_state IN ('created', 'starting')) AS connecting, | ||
| bool_and(workspace_agent.lifecycle_state = 'ready') AS connected | ||
| FROM workspace_agents workspace_agent | ||
| WHERE workspace_agent.id = task_app.workspace_agent_id | ||
| ) agent_status | ||
| CROSS JOIN LATERAL ( | ||
| SELECT | ||
| bool_or(workspace_app.health = 'unhealthy') AS any_unhealthy, | ||
| bool_or(workspace_app.health = 'initializing') AS any_initializing, | ||
| bool_and(workspace_app.health IN ('healthy', 'disabled')) AS all_healthy_or_disabled | ||
| FROM workspace_apps workspace_app | ||
| WHERE workspace_app.id = task_app.workspace_app_id | ||
| ) app_status | ||
| WHERE | ||
| tasks.deleted_at IS NULL; | ||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.