Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
chabad360 committed Jul 15, 2020
1 parent 58b3ee5 commit 7882348
Show file tree
Hide file tree
Showing 13 changed files with 12 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ Covey has, and will gain (in the coming weeks/months) a variety of features, inc
* [x] ~~Evaluate designing a very basic framework (for keeping things cleaner)~~
* [x] ~~Evaluate GraphQL for the API~~
* [x] Redesign DB using Gorm
* [ ] Fully implement (and test) the API
* [x] Fully implement (and test) the API
* [x] Swagger (OpenAPI)
* [ ] Fully document the API
* [x] Fully document the API

#### V0.6 Alpha

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

//revive:disable:cognitive-complexity
func Test_tokenGetAPI(t *testing.T) {
func TestTokenGetAPI(t *testing.T) {
var tests = []struct {
userid string
want string
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion common/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ func Recover() {
}
panic(fmt.Errorf("r: %v, type: %T", r, r))
}

}
3 changes: 3 additions & 0 deletions common/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"gorm.io/gorm"
)

// QueryParams parses a URL query and gets the items from the database based on it.
type QueryParams struct {
Limit int `form:"limit" validate:"min=0,max=50"`
Offset int `form:"offset"`
Expand All @@ -18,6 +19,7 @@ type QueryParams struct {
Expand bool `form:"expand"`
}

// Query runs a query against the database.
func (q *QueryParams) Query(table string, model interface{}, db *gorm.DB) error {
v := validator.New()
err := v.Struct(q)
Expand All @@ -44,6 +46,7 @@ func (q *QueryParams) Query(table string, model interface{}, db *gorm.DB) error
return nil
}

// Setup parses a url query.
func (q *QueryParams) Setup(r *http.Request) error {
q.Limit = 20
q.Offset = 0
Expand Down
2 changes: 1 addition & 1 deletion models/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type Job struct {
func (j *Job) GetIDShort() string { x, _ := hex.DecodeString(j.ID); return hex.EncodeToString(x[:8]) }

// BeforeCreate generates the job ID before saving.
func (j *Job) BeforeCreate(tx *gorm.DB) (err error) {
func (j *Job) BeforeCreate(_ *gorm.DB) (err error) {
j.ID = common.GenerateID(j)
j.IDShort = j.GetIDShort()
return nil
Expand Down
4 changes: 2 additions & 2 deletions models/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ type Node struct {
func (n *Node) GetIDShort() string { x, _ := hex.DecodeString(n.ID); return hex.EncodeToString(x[:8]) }

// BeforeCreate gets the short ID before saving.
func (n *Node) BeforeCreate(tx *gorm.DB) (err error) {
func (n *Node) BeforeCreate(_ *gorm.DB) (err error) {
n.IDShort = n.GetIDShort()
return nil
}

// AfterFind runs the setup for a node
func (n *Node) AfterFind(tx *gorm.DB) (err error) {
func (n *Node) AfterFind(_ *gorm.DB) (err error) {
return n.Setup()
}

Expand Down
2 changes: 1 addition & 1 deletion models/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type Task struct {
func (t *Task) GetIDShort() string { x, _ := hex.DecodeString(t.ID); return hex.EncodeToString(x[:8]) }

// BeforeCreate initializes the default values for a Task.
func (t *Task) BeforeCreate(tx *gorm.DB) (err error) {
func (t *Task) BeforeCreate(_ *gorm.DB) (err error) {
t.ExitCode = 258
t.State = StateQueued
t.ID = common.GenerateID(t)
Expand Down
12 changes: 2 additions & 10 deletions task/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ func initAgent(agent string) error {
return result.Error
}

if err := initQueues(t); err != nil {
return err
}

return nil
return initQueues(t)
}

// Init initializes the agent queues.
Expand All @@ -128,11 +124,7 @@ func Init() error {
return result.Error
}

if err := initQueues(t); err != nil {
return err
}

return nil
return initQueues(t)
}

// RegisterAgentHandlers registers the handler for receiving information from agents.
Expand Down

0 comments on commit 7882348

Please sign in to comment.