Skip to content

Commit

Permalink
fix: fix some lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Eraxyso authored Jan 14, 2025
1 parent c92364b commit c2031d6
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 13 deletions.
12 changes: 7 additions & 5 deletions controller/questionnaire.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ func (q Questionnaire) GetQuestionnaires(ctx echo.Context, userID string, params
}

func (q Questionnaire) PostQuestionnaire(c echo.Context, userID string, params openapi.PostQuestionnaireJSONRequestBody) (openapi.QuestionnaireDetail, error) {
_ = userID

responseDueDateTime := null.Time{}
if params.ResponseDueDateTime != nil {
responseDueDateTime.Valid = true
Expand Down Expand Up @@ -576,31 +578,31 @@ func (q Questionnaire) EditQuestionnaire(c echo.Context, questionnaireID int, pa

func (q Questionnaire) DeleteQuestionnaire(c echo.Context, questionnaireID int) error {
err := q.ITransaction.Do(c.Request().Context(), nil, func(ctx context.Context) error {
err := q.IQuestionnaire.DeleteQuestionnaire(c.Request().Context(), questionnaireID)
err := q.IQuestionnaire.DeleteQuestionnaire(ctx, questionnaireID)
if err != nil {
c.Logger().Errorf("failed to delete questionnaire: %+v", err)
return err
}

err = q.DeleteTargets(c.Request().Context(), questionnaireID)
err = q.DeleteTargets(ctx, questionnaireID)
if err != nil {
c.Logger().Errorf("failed to delete targets: %+v", err)
return err
}

err = q.DeleteAdministrators(c.Request().Context(), questionnaireID)
err = q.DeleteAdministrators(ctx, questionnaireID)
if err != nil {
c.Logger().Errorf("failed to delete administrators: %+v", err)
return err
}

questions, err := q.GetQuestions(c.Request().Context(), questionnaireID)
questions, err := q.GetQuestions(ctx, questionnaireID)
if err != nil {
c.Logger().Errorf("failed to get questions: %+v", err)
return err
}
for _, question := range questions {
err = q.DeleteQuestion(c.Request().Context(), question.ID)
err = q.DeleteQuestion(ctx, question.ID)
if err != nil {
c.Logger().Errorf("failed to delete administrators: %+v", err)
return err
Expand Down
9 changes: 6 additions & 3 deletions controller/reminder.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/traPtitech/anke-to/model"
"github.com/traPtitech/anke-to/traq"
"golang.org/x/sync/semaphore"
// "golang.org/x/sync/semaphore"
)

type Job struct {
Expand All @@ -24,7 +24,7 @@ type JobQueue struct {
}

var (
sem = semaphore.NewWeighted(1)
// sem = semaphore.NewWeighted(1)
Jq = &JobQueue{}
Wg = &sync.WaitGroup{}
reminderTimingMinutes = []int{5, 30, 60, 1440, 10080}
Expand Down Expand Up @@ -60,7 +60,10 @@ func (jq *JobQueue) PushReminder(questionnaireID int, limit *time.Time) error {
Timestamp: remindTimeStamp,
QuestionnaireID: questionnaireID,
Action: func() {
reminderAction(questionnaireID, reminderTimingStrings[i])
err := reminderAction(questionnaireID, reminderTimingStrings[i])
if err != nil {
panic(err)
}
},
})
}
Expand Down
2 changes: 2 additions & 0 deletions controller/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ func (r Response) GetResponse(ctx echo.Context, responseID openapi.ResponseIDInP
}

func (r Response) DeleteResponse(ctx echo.Context, responseID openapi.ResponseIDInPath, userID string) error {
_ = userID

limit, err := r.IQuestionnaire.GetQuestionnaireLimitByResponseID(ctx.Request().Context(), responseID)
if err != nil {
if errors.Is(err, model.ErrRecordNotFound) {
Expand Down
2 changes: 2 additions & 0 deletions model/questionnaires_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type Questionnaires struct {

// BeforeCreate Update時に自動でmodified_atを現在時刻に
func (questionnaire *Questionnaires) BeforeCreate(tx *gorm.DB) error {
_ = tx

now := time.Now()
questionnaire.ModifiedAt = now
questionnaire.CreatedAt = now
Expand Down
2 changes: 2 additions & 0 deletions model/questions_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type Questions struct {

// BeforeCreate Update時に自動でmodified_atを現在時刻に
func (questionnaire *Questions) BeforeCreate(tx *gorm.DB) error {
_ = tx

questionnaire.CreatedAt = time.Now()

return nil
Expand Down
2 changes: 2 additions & 0 deletions model/respondents_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type Respondents struct {

// BeforeCreate insert時に自動でmodifiedAt更新
func (r *Respondents) BeforeCreate(tx *gorm.DB) error {
_ = tx

r.ModifiedAt = time.Now()

return nil
Expand Down
2 changes: 2 additions & 0 deletions model/responses_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type Responses struct {

// BeforeCreate insert時に自動でmodifiedAt更新
func (r *Responses) BeforeCreate(tx *gorm.DB) error {
_ = tx

r.ModifiedAt = time.Now()

return nil
Expand Down
9 changes: 4 additions & 5 deletions model/validations_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func NewValidation() *Validation {
return new(Validation)
}

//Validations validationsテーブルの構造体
// Validations validationsテーブルの構造体
type Validations struct {
QuestionID int `json:"questionID" gorm:"type:int(11);not null;primaryKey"`
RegexPattern string `json:"regex_pattern" gorm:"type:text;default:NULL"`
Expand Down Expand Up @@ -152,16 +152,15 @@ func (*Validation) CheckTextValidation(validation Validations, Response string)
// CheckNumberValid MinBound,MaxBoundが指定されていれば,有効な入力か確認する
func (*Validation) CheckNumberValid(MinBound, MaxBound string) error {
var minBoundNum, maxBoundNum float64
var err error
if MinBound != "" {
min, err := strconv.ParseFloat(MinBound, 64)
minBoundNum = min
minBoundNum, err = strconv.ParseFloat(MinBound, 64)
if err != nil {
return fmt.Errorf("failed to check the boundary value. MinBound is not a numerical value: %w", ErrInvalidNumber)
}
}
if MaxBound != "" {
max, err := strconv.ParseFloat(MaxBound, 64)
maxBoundNum = max
maxBoundNum, err = strconv.ParseFloat(MaxBound, 64)
if err != nil {
return fmt.Errorf("failed to check the boundary value. MaxBound is not a numerical value: %w", ErrInvalidNumber)
}
Expand Down

0 comments on commit c2031d6

Please sign in to comment.