This commit is contained in:
inhosin 2019-09-19 10:14:22 +03:00
parent 61b976259a
commit d6387c3528
9 changed files with 69 additions and 81 deletions

View file

@ -7,7 +7,7 @@ import (
type Activity struct {
Id string `json:"id"`
Payload string `json:"note"`
Payload string `json:"status"`
Remote bool `json:"remote"`
Group `json:"group"`
CreatedAt time.Time `json:"created_at"`
@ -21,9 +21,9 @@ func GetActivity(db *sql.DB, slug string) (*Activity, error) {
FROM activity WHERE id = $1
`, slug)
var note Activity
err := row.Scan(&note.Slug,
&note.Name, &note.Note, &note.CreatedAt, &note.UpdatedAt)
var status Activity
err := row.Scan(&status.Id,
&status.Name, &status.Note, &status.CreatedAt, &status.UpdatedAt)
// This is not an error from the user's perspective
if err == sql.ErrNoRows {
@ -33,21 +33,21 @@ func GetActivity(db *sql.DB, slug string) (*Activity, error) {
return nil, err
}
return &note, nil
return &status, nil
}
/*
// PutNote creates a note with this name and note
func PutActivity(db *sql.DB, name string, note string) (string, error) {
// PutNote creates a status with this name and status
func PutActivity(db *sql.DB, name string, status string) (string, error) {
// TODO make guid but not slug
id := slugify.MakeLang(name, "en")
query := `
INSERT INTO activity (id, name, note)
INSERT INTO activity (id, name, status)
VALUES ($1, $2, $3)
`
_, err := db.Exec(query, slug, name, note)
_, err := db.Exec(query, slug, name, status)
return slug, err
}
*/

View file

@ -13,7 +13,7 @@ type Group struct {
gorm.Model
Id string `json:"id"`
Name string `json:"name"`
Note string `json:"note"`
Note string `json:"status"`
Type string
UserID uint
}
@ -21,12 +21,12 @@ type Group struct {
// GetGroup returns a single Group object or nil
func GetGroup(db *sql.DB, slug string) (*Group, error) {
row := db.QueryRow(`
select slug, name, note, created_at, updated_at
select slug, name, status, created_at, updated_at
from groups where slug = $1
`, slug)
var group Group
err := row.Scan(&group.id, &group.Name, &group.Note, &group.CreatedAt, &group.UpdatedAt)
err := row.Scan(&group.Id, &group.Name, &group.Note, &group.CreatedAt, &group.UpdatedAt)
if err == sql.ErrNoRows {
return nil, nil
@ -43,7 +43,7 @@ func PutGroup(db *sql.DB, name string, note string) (string, error) {
slug := slugify.MakeLang(name, "en")
query := `
insert into groups(slug, name, note)
insert into groups(slug, name, status)
values ($1, $2, $3)
`
_, err := db.Exec(query, slug, name, note)