Skip to content

Commit 1a5c56c

Browse files
committed
Fix query
1 parent 29b76a0 commit 1a5c56c

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

coderd/projects.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
// abstracted for ease of change later on.
2525
type Project database.Project
2626

27-
// ProjectHistory is the JSON representation of a Coder project version.
27+
// ProjectHistory is the JSON representation of Coder project version history.
2828
type ProjectHistory struct {
2929
ID uuid.UUID `json:"id"`
3030
ProjectID uuid.UUID `json:"project_id"`
@@ -149,8 +149,8 @@ func (*projects) project(rw http.ResponseWriter, r *http.Request) {
149149
render.JSON(rw, r, project)
150150
}
151151

152-
// projectHistory lists versions for a single project.
153-
func (p *projects) projectHistory(rw http.ResponseWriter, r *http.Request) {
152+
// allProjectHistory lists all history for a single project.
153+
func (p *projects) allProjectHistory(rw http.ResponseWriter, r *http.Request) {
154154
project := httpmw.ProjectParam(r)
155155

156156
history, err := p.Database.GetProjectHistoryByProjectID(r.Context(), project.ID)
@@ -163,14 +163,17 @@ func (p *projects) projectHistory(rw http.ResponseWriter, r *http.Request) {
163163
})
164164
return
165165
}
166-
versions := make([]ProjectHistory, 0)
166+
apiHistory := make([]ProjectHistory, 0)
167167
for _, version := range history {
168-
versions = append(versions, convertProjectHistory(version))
168+
apiHistory = append(apiHistory, convertProjectHistory(version))
169169
}
170170
render.Status(r, http.StatusOK)
171-
render.JSON(rw, r, versions)
171+
render.JSON(rw, r, apiHistory)
172172
}
173173

174+
// createProjectHistory adds a new historical version of a project.
175+
// An import job is queued to parse the storage method provided.
176+
// Once completed, the import job will specify the version as latest.
174177
func (p *projects) createProjectHistory(rw http.ResponseWriter, r *http.Request) {
175178
var createProjectVersion CreateProjectVersionRequest
176179
if !httpapi.Read(rw, r, &createProjectVersion) {
@@ -203,6 +206,8 @@ func (p *projects) createProjectHistory(rw http.ResponseWriter, r *http.Request)
203206
Name: namesgenerator.GetRandomName(1),
204207
StorageMethod: createProjectVersion.StorageMethod,
205208
StorageSource: createProjectVersion.StorageSource,
209+
// TODO: Make this do something!
210+
ImportJobID: uuid.New(),
206211
})
207212
if err != nil {
208213
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{

database/query.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ FROM
163163
workspace_history
164164
WHERE
165165
workspace_id = $1
166-
AND workspace__after_id IS NULL
166+
AND after_id IS NULL
167167
LIMIT
168168
1;
169169

database/query.sql.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)