From 1d8b54eba630f72605f9a17c05e1f8c60298979a Mon Sep 17 00:00:00 2001 From: Anass Bouassaba Date: Thu, 8 Aug 2024 08:08:18 +0200 Subject: [PATCH] refactor(api): stylecheck suggestions (#255) --- api/repo/task_repo.go | 84 +++++++++++++++++------------------ api/router/snapshot_router.go | 6 +-- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/api/repo/task_repo.go b/api/repo/task_repo.go index fe907fb4d..cf9f8ff69 100644 --- a/api/repo/task_repo.go +++ b/api/repo/task_repo.go @@ -41,103 +41,103 @@ func (*taskEntity) TableName() string { return "task" } -func (o *taskEntity) BeforeCreate(*gorm.DB) (err error) { - o.CreateTime = helper.NewTimestamp() +func (e *taskEntity) BeforeCreate(*gorm.DB) (err error) { + e.CreateTime = helper.NewTimestamp() return nil } -func (o *taskEntity) BeforeSave(*gorm.DB) (err error) { +func (e *taskEntity) BeforeSave(*gorm.DB) (err error) { timeNow := helper.NewTimestamp() - o.UpdateTime = &timeNow + e.UpdateTime = &timeNow return nil } -func (p *taskEntity) GetID() string { - return p.ID +func (e *taskEntity) GetID() string { + return e.ID } -func (p *taskEntity) GetName() string { - return p.Name +func (e *taskEntity) GetName() string { + return e.Name } -func (p *taskEntity) GetError() *string { - return p.Error +func (e *taskEntity) GetError() *string { + return e.Error } -func (p *taskEntity) GetPercentage() *int { - return p.Percentage +func (e *taskEntity) GetPercentage() *int { + return e.Percentage } -func (p *taskEntity) GetIsIndeterminate() bool { - return p.IsIndeterminate +func (e *taskEntity) GetIsIndeterminate() bool { + return e.IsIndeterminate } -func (p *taskEntity) GetUserID() string { - return p.UserID +func (e *taskEntity) GetUserID() string { + return e.UserID } -func (p *taskEntity) GetStatus() string { - return p.Status +func (e *taskEntity) GetStatus() string { + return e.Status } -func (s *taskEntity) GetPayload() map[string]string { - if s.Payload.String() == "" { +func (e *taskEntity) GetPayload() map[string]string { + if e.Payload.String() == "" { return nil } res := map[string]string{} - if err := json.Unmarshal([]byte(s.Payload.String()), &res); err != nil { + if err := json.Unmarshal([]byte(e.Payload.String()), &res); err != nil { log.GetLogger().Fatal(err) return nil } return res } -func (o *taskEntity) GetCreateTime() string { - return o.CreateTime +func (e *taskEntity) GetCreateTime() string { + return e.CreateTime } -func (o *taskEntity) GetUpdateTime() *string { - return o.UpdateTime +func (e *taskEntity) GetUpdateTime() *string { + return e.UpdateTime } -func (p *taskEntity) HasError() bool { - return p.Error != nil +func (e *taskEntity) HasError() bool { + return e.Error != nil } -func (p *taskEntity) SetName(name string) { - p.Name = name +func (e *taskEntity) SetName(name string) { + e.Name = name } -func (p *taskEntity) SetError(error *string) { - p.Error = error +func (e *taskEntity) SetError(error *string) { + e.Error = error } -func (p *taskEntity) SetPercentage(percentage *int) { - p.Percentage = percentage +func (e *taskEntity) SetPercentage(percentage *int) { + e.Percentage = percentage } -func (p *taskEntity) SetIsIndeterminate(isIndeterminate bool) { - p.IsIndeterminate = isIndeterminate +func (e *taskEntity) SetIsIndeterminate(isIndeterminate bool) { + e.IsIndeterminate = isIndeterminate } -func (p *taskEntity) SetUserID(userID string) { - p.UserID = userID +func (e *taskEntity) SetUserID(userID string) { + e.UserID = userID } -func (p *taskEntity) SetStatus(status string) { - p.Status = status +func (e *taskEntity) SetStatus(status string) { + e.Status = status } -func (s *taskEntity) SetPayload(p map[string]string) { +func (e *taskEntity) SetPayload(p map[string]string) { if p == nil { - s.Payload = nil + e.Payload = nil } else { b, err := json.Marshal(p) if err != nil { log.GetLogger().Fatal(err) return } - if err := s.Payload.UnmarshalJSON(b); err != nil { + if err := e.Payload.UnmarshalJSON(b); err != nil { log.GetLogger().Fatal(err) } } diff --git a/api/router/snapshot_router.go b/api/router/snapshot_router.go index 21a1e42c1..c3f1bc33a 100644 --- a/api/router/snapshot_router.go +++ b/api/router/snapshot_router.go @@ -62,8 +62,8 @@ func (r *SnapshotRouter) AppendNonJWTRoutes(g fiber.Router) { // @Router /snapshots [get] func (r *SnapshotRouter) List(c *fiber.Ctx) error { var err error - fileId := c.Query("file_id") - if fileId == "" { + fileID := c.Query("file_id") + if fileID == "" { return errorpkg.NewMissingQueryParamError("file_id") } var page int64 @@ -92,7 +92,7 @@ func (r *SnapshotRouter) List(c *fiber.Ctx) error { if !IsValidSortOrder(sortOrder) { return errorpkg.NewInvalidQueryParamError("sort_order") } - res, err := r.snapshotSvc.List(fileId, service.SnapshotListOptions{ + res, err := r.snapshotSvc.List(fileID, service.SnapshotListOptions{ Page: uint(page), Size: uint(size), SortBy: sortBy,