From e99c7b69e0981d4a7b87310cd811b90a2ffbe12f Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 3 Jun 2017 11:22:08 +0200 Subject: Comment out all the things! Half get rid of a lot of code. I don't like and don't want to use our old field types. Get rid of them and the code in 'http.go' that depends on them. Also get rid of the time entry submission code in 'main.go' as that's going to be redone. --- timetask/fields.go | 160 ++++++++++++++++++++++++++--------------------------- 1 file changed, 80 insertions(+), 80 deletions(-) (limited to 'timetask/fields.go') diff --git a/timetask/fields.go b/timetask/fields.go index fb3a026..f3bb27d 100644 --- a/timetask/fields.go +++ b/timetask/fields.go @@ -1,85 +1,85 @@ package timetask -import "fmt" +// import "fmt" -type Client struct { - ID int - Name string - Projects []Project -} +// type Client struct { +// ID int +// Name string +// Projects []Project +// } -type Project struct { - ID int - Name string - Modules []Module - Tasks []Task - WorkTypes []WorkType `yaml:"work_types"` -} +// type Project struct { +// ID int +// Name string +// Modules []Module +// Tasks []Task +// WorkTypes []WorkType `yaml:"work_types"` +// } -type Module struct { - ID int - Name string -} -type Task struct { - ID int - Name string -} -type WorkType struct { - ID int - Name string -} - -type Fields struct { - PersonID int `yaml:"person_id"` - Clients []Client -} - -func (f *Fields) ClientByName(client_name string) (*Client, error) { - for _, client := range f.Clients { - if client.Name == client_name { - return &client, nil - } - } - - return nil, fmt.Errorf("Client %s not found", client_name) -} - -func (c *Client) ProjectByName(project_name string) (*Project, error) { - for _, project := range c.Projects { - if project.Name == project_name { - return &project, nil - } - } - - return nil, fmt.Errorf("Project %s not found", project_name) -} - -func (p *Project) ModuleByName(module_name string) (*Module, error) { - for _, module := range p.Modules { - if module.Name == module_name { - return &module, nil - } - } - - return nil, fmt.Errorf("Module %s not found", module_name) -} - -func (p *Project) TaskByName(task_name string) (*Task, error) { - for _, task := range p.Tasks { - if task.Name == task_name { - return &task, nil - } - } - - return nil, fmt.Errorf("Task %s not found", task_name) -} - -func (p *Project) WorkTypeByName(work_type_name string) (*WorkType, error) { - for _, work_type := range p.WorkTypes { - if work_type.Name == work_type_name { - return &work_type, nil - } - } - - return nil, fmt.Errorf("Work type %s not found", work_type_name) -} +// type Module struct { +// ID int +// Name string +// } +// type Task struct { +// ID int +// Name string +// } +// type WorkType struct { +// ID int +// Name string +// } +// +// type Fields struct { +// PersonID int `yaml:"person_id"` +// Clients []Client +// } +// +// func (f *Fields) ClientByName(client_name string) (*Client, error) { +// for _, client := range f.Clients { +// if client.Name == client_name { +// return &client, nil +// } +// } +// +// return nil, fmt.Errorf("Client %s not found", client_name) +// } +// +// func (c *Client) ProjectByName(project_name string) (*Project, error) { +// for _, project := range c.Projects { +// if project.Name == project_name { +// return &project, nil +// } +// } +// +// return nil, fmt.Errorf("Project %s not found", project_name) +// } +// +// func (p *Project) ModuleByName(module_name string) (*Module, error) { +// for _, module := range p.Modules { +// if module.Name == module_name { +// return &module, nil +// } +// } +// +// return nil, fmt.Errorf("Module %s not found", module_name) +// } +// +// func (p *Project) TaskByName(task_name string) (*Task, error) { +// for _, task := range p.Tasks { +// if task.Name == task_name { +// return &task, nil +// } +// } +// +// return nil, fmt.Errorf("Task %s not found", task_name) +// } +// +// func (p *Project) WorkTypeByName(work_type_name string) (*WorkType, error) { +// for _, work_type := range p.WorkTypes { +// if work_type.Name == work_type_name { +// return &work_type, nil +// } +// } +// +// return nil, fmt.Errorf("Work type %s not found", work_type_name) +// } -- cgit v1.2.3 From d998a82d4019b1fc5a15734f091852b1b0f086d4 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 3 Jun 2017 11:24:55 +0200 Subject: Create a new Project type This corresponds to a "project" entry in the new config2.toml file. (See 13c84cd9973458750305c72a919cf921d9b22b04). Instead of decoding generic `interface{}`s as projects from the TOML, make them a real type. The reason why we're using `int`s where we used to use strings is that the new TOML format will have users write IDs directly in the config file, instead of having the program automatically search for those IDs and use them as we had previously designed. Maybe we'll bring that functionality back at some point, but for now it's too bothersome to implement and I don't consider it worth the trouble. --- timetask/fields.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'timetask/fields.go') diff --git a/timetask/fields.go b/timetask/fields.go index f3bb27d..da2b37d 100644 --- a/timetask/fields.go +++ b/timetask/fields.go @@ -16,6 +16,16 @@ package timetask // WorkTypes []WorkType `yaml:"work_types"` // } +type Project struct { + Client int + Project int + Module int + Task int + WorkType int + Time int + Billable bool +} + // type Module struct { // ID int // Name string -- cgit v1.2.3