Skip to content

fix: update template updated_at value #2729

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

Merged
merged 2 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions coderd/database/databasefake/databasefake.go
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,7 @@ func (q *fakeQuerier) UpdateTemplateActiveVersionByID(_ context.Context, arg dat
continue
}
template.ActiveVersionID = arg.ActiveVersionID
template.UpdatedAt = arg.UpdatedAt
q.templates[index] = template
return nil
}
Expand All @@ -1845,6 +1846,7 @@ func (q *fakeQuerier) UpdateTemplateDeletedByID(_ context.Context, arg database.
continue
}
template.Deleted = arg.Deleted
template.UpdatedAt = arg.UpdatedAt
q.templates[index] = template
return nil
}
Expand Down Expand Up @@ -1876,7 +1878,7 @@ func (q *fakeQuerier) UpdateTemplateVersionDescriptionByJobID(_ context.Context,
continue
}
templateVersion.Readme = arg.Readme
templateVersion.UpdatedAt = database.Now()
templateVersion.UpdatedAt = arg.UpdatedAt
q.templateVersions[index] = templateVersion
return nil
}
Expand Down Expand Up @@ -1910,6 +1912,7 @@ func (q *fakeQuerier) UpdateWorkspaceAgentConnectionByID(_ context.Context, arg
agent.FirstConnectedAt = arg.FirstConnectedAt
agent.LastConnectedAt = arg.LastConnectedAt
agent.DisconnectedAt = arg.DisconnectedAt
agent.UpdatedAt = arg.UpdatedAt
q.provisionerJobAgents[index] = agent
return nil
}
Expand All @@ -1927,7 +1930,7 @@ func (q *fakeQuerier) UpdateWorkspaceAgentKeysByID(_ context.Context, arg databa

agent.WireguardNodePublicKey = arg.WireguardNodePublicKey
agent.WireguardDiscoPublicKey = arg.WireguardDiscoPublicKey
agent.UpdatedAt = database.Now()
agent.UpdatedAt = arg.UpdatedAt
q.provisionerJobAgents[index] = agent
return nil
}
Expand Down
43 changes: 28 additions & 15 deletions coderd/database/queries.sql.go

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

6 changes: 4 additions & 2 deletions coderd/database/queries/templates.sql
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,17 @@ VALUES
UPDATE
templates
SET
active_version_id = $2
active_version_id = $2,
updated_at = $3
WHERE
id = $1;

-- name: UpdateTemplateDeletedByID :exec
UPDATE
templates
SET
deleted = $2
deleted = $2,
updated_at = $3
WHERE
id = $1;

Expand Down
2 changes: 1 addition & 1 deletion coderd/database/queries/templateversions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ UPDATE
template_versions
SET
readme = $2,
updated_at = now()
updated_at = $3
WHERE
job_id = $1;
8 changes: 4 additions & 4 deletions coderd/database/queries/workspaceagents.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ VALUES
UPDATE
workspace_agents
SET
updated_at = now(),
first_connected_at = $2,
last_connected_at = $3,
disconnected_at = $4
disconnected_at = $4,
updated_at = $5
WHERE
id = $1;

-- name: UpdateWorkspaceAgentKeysByID :exec
UPDATE
workspace_agents
SET
updated_at = now(),
wireguard_node_public_key = $2,
wireguard_disco_public_key = $3
wireguard_disco_public_key = $3,
updated_at = $4
WHERE
id = $1;
5 changes: 3 additions & 2 deletions coderd/provisionerdaemons.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,9 @@ func (server *provisionerdServer) UpdateJob(ctx context.Context, request *proto.

if len(request.Readme) > 0 {
err := server.Database.UpdateTemplateVersionDescriptionByJobID(ctx, database.UpdateTemplateVersionDescriptionByJobIDParams{
JobID: job.ID,
Readme: string(request.Readme),
JobID: job.ID,
Readme: string(request.Readme),
UpdatedAt: database.Now(),
})
if err != nil {
return nil, xerrors.Errorf("update template version description: %w", err)
Expand Down
5 changes: 3 additions & 2 deletions coderd/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ func (api *API) deleteTemplate(rw http.ResponseWriter, r *http.Request) {
return
}
err = api.Database.UpdateTemplateDeletedByID(r.Context(), database.UpdateTemplateDeletedByIDParams{
ID: template.ID,
Deleted: true,
ID: template.ID,
Deleted: true,
UpdatedAt: database.Now(),
})
if err != nil {
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
Expand Down
1 change: 1 addition & 0 deletions coderd/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ func (api *API) patchActiveTemplateVersion(rw http.ResponseWriter, r *http.Reque
err = store.UpdateTemplateActiveVersionByID(r.Context(), database.UpdateTemplateActiveVersionByIDParams{
ID: template.ID,
ActiveVersionID: req.ID,
UpdatedAt: database.Now(),
})
if err != nil {
return xerrors.Errorf("update active version: %w", err)
Expand Down
2 changes: 2 additions & 0 deletions coderd/workspaceagents.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ func (api *API) workspaceAgentListen(rw http.ResponseWriter, r *http.Request) {
FirstConnectedAt: firstConnectedAt,
LastConnectedAt: lastConnectedAt,
DisconnectedAt: disconnectedAt,
UpdatedAt: database.Now(),
})
if err != nil {
return err
Expand Down Expand Up @@ -491,6 +492,7 @@ func (api *API) postWorkspaceAgentKeys(rw http.ResponseWriter, r *http.Request)
ID: workspaceAgent.ID,
WireguardNodePublicKey: dbtypes.NodePublic(keys.Public),
WireguardDiscoPublicKey: dbtypes.DiscoPublic(keys.Disco),
UpdatedAt: database.Now(),
})
if err != nil {
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
Expand Down