feat: support custom order of agent metadata (#12066)

This commit is contained in:
Marcin Tojek
2024-02-08 17:29:34 +01:00
committed by GitHub
parent e659957b65
commit c0e169ebf9
23 changed files with 438 additions and 316 deletions
+1
View File
@@ -5687,6 +5687,7 @@ func (q *FakeQuerier) InsertWorkspaceAgentMetadata(_ context.Context, arg databa
Key: arg.Key,
Timeout: arg.Timeout,
Interval: arg.Interval,
DisplayOrder: arg.DisplayOrder,
}
q.workspaceAgentMetadata = append(q.workspaceAgentMetadata, metadatum)
+4 -1
View File
@@ -950,9 +950,12 @@ CREATE UNLOGGED TABLE workspace_agent_metadata (
error character varying(65535) DEFAULT ''::character varying NOT NULL,
timeout bigint NOT NULL,
"interval" bigint NOT NULL,
collected_at timestamp with time zone DEFAULT '0001-01-01 00:00:00+00'::timestamp with time zone NOT NULL
collected_at timestamp with time zone DEFAULT '0001-01-01 00:00:00+00'::timestamp with time zone NOT NULL,
display_order integer DEFAULT 0 NOT NULL
);
COMMENT ON COLUMN workspace_agent_metadata.display_order IS 'Specifies the order in which to display agent metadata in user interfaces.';
CREATE TABLE workspace_agent_scripts (
workspace_agent_id uuid NOT NULL,
log_source_id uuid NOT NULL,
@@ -0,0 +1 @@
ALTER TABLE workspace_agent_metadata DROP COLUMN display_order;
@@ -0,0 +1,4 @@
ALTER TABLE workspace_agent_metadata ADD COLUMN display_order integer NOT NULL DEFAULT 0;
COMMENT ON COLUMN workspace_agent_metadata.display_order
IS 'Specifies the order in which to display agent metadata in user interfaces.';
+2
View File
@@ -2268,6 +2268,8 @@ type WorkspaceAgentMetadatum struct {
Timeout int64 `db:"timeout" json:"timeout"`
Interval int64 `db:"interval" json:"interval"`
CollectedAt time.Time `db:"collected_at" json:"collected_at"`
// Specifies the order in which to display agent metadata in user interfaces.
DisplayOrder int32 `db:"display_order" json:"display_order"`
}
type WorkspaceAgentScript struct {
+7 -3
View File
@@ -8457,7 +8457,7 @@ func (q *sqlQuerier) GetWorkspaceAgentLogsAfter(ctx context.Context, arg GetWork
const getWorkspaceAgentMetadata = `-- name: GetWorkspaceAgentMetadata :many
SELECT
workspace_agent_id, display_name, key, script, value, error, timeout, interval, collected_at
workspace_agent_id, display_name, key, script, value, error, timeout, interval, collected_at, display_order
FROM
workspace_agent_metadata
WHERE
@@ -8489,6 +8489,7 @@ func (q *sqlQuerier) GetWorkspaceAgentMetadata(ctx context.Context, arg GetWorks
&i.Timeout,
&i.Interval,
&i.CollectedAt,
&i.DisplayOrder,
); err != nil {
return nil, err
}
@@ -8925,10 +8926,11 @@ INSERT INTO
key,
script,
timeout,
interval
interval,
display_order
)
VALUES
($1, $2, $3, $4, $5, $6)
($1, $2, $3, $4, $5, $6, $7)
`
type InsertWorkspaceAgentMetadataParams struct {
@@ -8938,6 +8940,7 @@ type InsertWorkspaceAgentMetadataParams struct {
Script string `db:"script" json:"script"`
Timeout int64 `db:"timeout" json:"timeout"`
Interval int64 `db:"interval" json:"interval"`
DisplayOrder int32 `db:"display_order" json:"display_order"`
}
func (q *sqlQuerier) InsertWorkspaceAgentMetadata(ctx context.Context, arg InsertWorkspaceAgentMetadataParams) error {
@@ -8948,6 +8951,7 @@ func (q *sqlQuerier) InsertWorkspaceAgentMetadata(ctx context.Context, arg Inser
arg.Script,
arg.Timeout,
arg.Interval,
arg.DisplayOrder,
)
return err
}
+3 -2
View File
@@ -103,10 +103,11 @@ INSERT INTO
key,
script,
timeout,
interval
interval,
display_order
)
VALUES
($1, $2, $3, $4, $5, $6);
($1, $2, $3, $4, $5, $6, $7);
-- name: UpdateWorkspaceAgentMetadata :exec
WITH metadata AS (