repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
36b9540
parent
4e6f6f8
author
Eric Bower
date
2023-11-12 17:15:47 +0000 UTC
fix(pgs): load created_at and updated_at for projects
1 files changed,  +9, -2
M db/postgres/storage.go
+9, -2
 1@@ -255,10 +255,10 @@ const (
 2 
 3 	sqlInsertProject      = `INSERT INTO projects (user_id, name, project_dir) VALUES ($1, $2, $3) RETURNING id;`
 4 	sqlUpdateProject      = `UPDATE projects SET updated_at = $3 WHERE user_id = $1 AND name = $2;`
 5-	sqlFindProjectByName  = `SELECT id, user_id, name, project_dir FROM projects WHERE user_id = $1 AND name = $2;`
 6+	sqlFindProjectByName  = `SELECT id, user_id, name, project_dir, created_at, updated_at FROM projects WHERE user_id = $1 AND name = $2;`
 7 	sqlSelectProjectCount = `SELECT count(id) FROM projects`
 8 	sqlFindAllProjects    = `
 9-	SELECT projects.id, user_id, app_users.name as username, projects.name, project_dir, projects.created_at
10+	SELECT projects.id, user_id, app_users.name as username, projects.name, project_dir, projects.created_at, projects.updated_at
11 	FROM projects
12 	LEFT JOIN app_users ON app_users.id = projects.user_id
13 	ORDER BY created_at ASC
14@@ -1288,6 +1288,8 @@ func (me *PsqlDB) FindProjectByName(userID, name string) (*db.Project, error) {
15 		&project.UserID,
16 		&project.Name,
17 		&project.ProjectDir,
18+		&project.CreatedAt,
19+		&project.UpdatedAt,
20 	)
21 	if err != nil {
22 		return nil, err
23@@ -1309,6 +1311,8 @@ func (me *PsqlDB) FindProjectLinks(userID, name string) ([]*db.Project, error) {
24 			&project.UserID,
25 			&project.Name,
26 			&project.ProjectDir,
27+			&project.CreatedAt,
28+			&project.UpdatedAt,
29 		)
30 		if err != nil {
31 			return nil, err
32@@ -1337,6 +1341,8 @@ func (me *PsqlDB) FindProjectsByPrefix(userID, prefix string) ([]*db.Project, er
33 			&project.UserID,
34 			&project.Name,
35 			&project.ProjectDir,
36+			&project.CreatedAt,
37+			&project.UpdatedAt,
38 		)
39 		if err != nil {
40 			return nil, err
41@@ -1397,6 +1403,7 @@ func (me *PsqlDB) FindAllProjects(page *db.Pager) (*db.Paginate[*db.Project], er
42 			&project.Name,
43 			&project.ProjectDir,
44 			&project.CreatedAt,
45+			&project.UpdatedAt,
46 		)
47 		if err != nil {
48 			return nil, err