mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-30 00:11:45 +08:00
Merge pull request #884 from Vafilor/feat/filtering.updates
feat: updated workflow/workspace fields to allow some related field queries
This commit is contained in:
@@ -2396,12 +2396,19 @@ func (c *Client) UpdateWorkflowExecutionMetrics(namespace, uid string, metrics M
|
||||
|
||||
// ListWorkflowExecutionsField loads all of the distinct field values for workflow executions
|
||||
func (c *Client) ListWorkflowExecutionsField(namespace, field string) (value []string, err error) {
|
||||
if field != "name" {
|
||||
columnName := ""
|
||||
|
||||
switch field {
|
||||
case "name":
|
||||
columnName = "we.name"
|
||||
break
|
||||
case "templateName":
|
||||
columnName = "wt.name"
|
||||
break
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported field '%v'", field)
|
||||
}
|
||||
|
||||
columnName := fmt.Sprintf("we.%v", field)
|
||||
|
||||
sb := sb.Select(columnName).
|
||||
Distinct().
|
||||
From("workflow_executions we").
|
||||
|
||||
@@ -985,18 +985,29 @@ func (c *Client) GetWorkspaceContainerLogs(namespace, uid, containerName string,
|
||||
|
||||
// ListWorkspacesField loads all of the distinct field values for workspaces
|
||||
func (c *Client) ListWorkspacesField(namespace, field string) (value []string, err error) {
|
||||
if field != "name" {
|
||||
columnName := ""
|
||||
|
||||
switch field {
|
||||
case "name":
|
||||
columnName = "w.name"
|
||||
break
|
||||
case "templateName":
|
||||
columnName = "wt.name"
|
||||
break
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported field '%v'", field)
|
||||
}
|
||||
|
||||
columnName := fmt.Sprintf("w.%v", field)
|
||||
|
||||
sb := sb.Select(columnName).
|
||||
Distinct().
|
||||
From("workspaces w").
|
||||
Where(sq.Eq{
|
||||
Join("workspace_templates wt ON w.workspace_template_id = wt.id").
|
||||
Where(sq.And{
|
||||
sq.Eq{
|
||||
"w.namespace": namespace,
|
||||
}).OrderBy(columnName)
|
||||
}, sq.NotEq{
|
||||
"w.phase": WorkspaceTerminated,
|
||||
}}).OrderBy(columnName)
|
||||
|
||||
err = c.DB.Selectx(&value, sb)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user