Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesread committed Feb 18, 2024
1 parent cf122fc commit 05a3432
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 11 deletions.
45 changes: 38 additions & 7 deletions pkg/db/dummy/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,21 @@ func (db *Dummy) setup() {
db.tasks = []dbconn.DBTask{
dbconn.DBTask{
ID: "1",
Content: "First Task",
Content: "First List Task One",
ParentType: "list",
ParentId: "1",
},
dbconn.DBTask{
ID: "2",
Content: "Second Task",
Content: "Second List Task One",
ParentType: "list",
ParentId: "2",
},
dbconn.DBTask{
ID: "3",
Content: "Second List Task Two",
ParentType: "list",
ParentId: "2",
},
}

Expand All @@ -43,12 +53,12 @@ func (db *Dummy) setup() {
dbconn.DBList{
ID: "1",
Title: "First list",
CountTasks: 9,
CountTasks: 1,
},
dbconn.DBList{
ID: "2",
Title: "Second list",
CountTasks: 4,
CountTasks: 2,
},
}
}
Expand All @@ -57,6 +67,16 @@ func (db *Dummy) Print() {
log.Infof("foo %+v", db)
}

func (db *Dummy) GetTask(taskId string) (*dbconn.DBTask, error) {
for _, task := range db.tasks {
if task.ID == taskId {
return &task, nil
}
}

return nil, nil
}

func (db *Dummy) GetTasks(listId string) ([]dbconn.DBTask, error) {
return db.tasks, nil
}
Expand All @@ -69,11 +89,22 @@ func (db *Dummy) GetLists() ([]dbconn.DBList, error) {
return db.lists, nil
}

func (db *Dummy) CreateTask(content string) error {
func (db *Dummy) CreateList(content string) error {
db.lists = append(db.lists, dbconn.DBList{
ID: uuid.New().String(),
Title: content,
})

return nil
}

func (db *Dummy) CreateTask(content string) (string, error) {
id := uuid.New().String()

db.tasks = append(db.tasks, dbconn.DBTask{
ID: uuid.New().String(),
ID: id,
Content: content,
})

return nil
return id, nil
}
3 changes: 2 additions & 1 deletion pkg/db/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ type DB interface {
Connect() error
Print()
GetTags() ([]DBTag, error)
GetTask(id string) (*DBTask, error)
GetTasks(listId string) ([]DBTask, error)
GetLists() ([]DBList, error)
CreateTask(content string) error
CreateTask(content string) (string, error)
CreateList(content string) error
}
12 changes: 12 additions & 0 deletions pkg/db/neo4j/neo4j.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"github.com/neo4j/neo4j-go-driver/v5/neo4j/dbtype"
db "github.com/wacky-tracky/wacky-tracky-server/pkg/db"

"github.com/google/uuid"

log "github.com/sirupsen/logrus"

"fmt"
Expand Down Expand Up @@ -200,6 +202,10 @@ func GetSubItems(itemId int64) []db.DBTask {
return ret
}

func (api Neo4jDB) GetTask(listId string) (*db.DBTask, error) {
return nil, nil
}

func (api Neo4jDB) GetTasks(listId string) ([]db.DBTask, error) {
var ret []db.DBTask

Expand Down Expand Up @@ -233,3 +239,9 @@ func (api Neo4jDB) GetTasks(listId string) ([]db.DBTask, error) {

return ret, nil
}

func (api Neo4jDB) CreateTask(title string) (string, error) {
id := uuid.New().String()

return id, nil
}
15 changes: 13 additions & 2 deletions pkg/db/yamlfiles/yamlfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,19 @@ func (drv *YamlFileDriver) Connect() error {
func (drv *YamlFileDriver) Print() {
}

func (drv *YamlFileDriver) CreateTask(content string) error {
func (drv *YamlFileDriver) CreateTask(content string) (string, error) {
id := uuid.New().String()

task := db.DBTask {
Content: content,
ID: id,
}

tasks = append(tasks, task)

save(filenameTasks, tasks)

return nil
return id, nil
}

func (drv *YamlFileDriver) GetLists() ([]db.DBList, error) {
Expand All @@ -83,6 +86,14 @@ func (drv *YamlFileDriver) GetTags() ([]db.DBTag, error) {
return tags, nil
}

func (drv *YamlFileDriver) GetTask(taskId string) (*db.DBTask, error) {
task := &db.DBTask {

}

return task, nil
}

func (drv *YamlFileDriver) GetTasks(listId string) ([]db.DBTask, error) {

return tasks, nil
Expand Down
6 changes: 5 additions & 1 deletion pkg/grpcapi/grpcapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ func (api *wackyTrackyClientService) DeleteTask(ctx context.Context, req *pb.Del
func (api *wackyTrackyClientService) CreateTask(ctx context.Context, req *pb.CreateTaskRequest) (*pb.CreateTaskResponse, error) {
dbconn.CreateTask(req.Content)

res := &pb.CreateTaskResponse{}


res := &pb.CreateTaskResponse{

}

return res, nil
}
Expand Down
1 change: 1 addition & 0 deletions wt.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ message CreateTaskRequest {
}

message CreateTaskResponse {
Task task = 1;
}

message DeleteTaskRequest {
Expand Down

0 comments on commit 05a3432

Please sign in to comment.