Skip to content

Commit

Permalink
change requests
Browse files Browse the repository at this point in the history
  • Loading branch information
kish1n committed Aug 29, 2024
1 parent 864e0bc commit 543a036
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
3 changes: 1 addition & 2 deletions internal/service/handlers/daily_question_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func EditDailyQuestion(w http.ResponseWriter, r *http.Request) {

req, err := requests.NewDailyQuestionEdit(r)
if err != nil {

Log(r).WithError(err).Error("Error creating daily question edit request")
ape.RenderErr(w, problems.InternalError())
return
Expand Down Expand Up @@ -87,7 +86,7 @@ func EditDailyQuestion(w http.ResponseWriter, r *http.Request) {
return
}
if question != nil && ID != question.ID {
Log(r).Errorf("Error on this day %v, the daily question already has %v", question.StartsAt, question)
Log(r).Errorf("Error on this day %s, the daily question already has %s", question.StartsAt.String(), question)
ape.RenderErr(w, problems.Conflict())
return
}
Expand Down
9 changes: 3 additions & 6 deletions internal/service/requests/daily_question_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ func NewDailyQuestion(r *http.Request) (req resources.DailyQuestionCreateRespons
}

return req, validation.Errors{
"data/attributes/time_for_answer": validation.Validate(req.Data.Attributes.TimeForAnswer, validation.Required),
"data/attributes/correct_answer": validation.Validate(req.Data.Attributes.CorrectAnswer, validation.Required),
"data/attributes/starts_at": validation.Validate(req.Data.Attributes.StartsAt, validation.Required),
"data/attributes/options": validation.Validate(req.Data.Attributes.Options, validation.Required),
"data/attributes/reward": validation.Validate(req.Data.Attributes.Reward, validation.Required),
"data/attributes/title": validation.Validate(req.Data.Attributes.Title, validation.Required),
"data/id": validation.Validate(&req.Data.ID, validation.Required),
"data/type": validation.Validate(&req.Data.Type, validation.Required),
"data/attributes": validation.Validate(&req.Data.Attributes, validation.Required),
}.Filter()
}
9 changes: 3 additions & 6 deletions internal/service/requests/daily_question_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ func NewDailyQuestionEdit(r *http.Request) (req resources.DailyQuestionEditRespo
}

return req, validation.Errors{
"time_for_answer": validation.Validate(&req.Data.Attributes.TimeForAnswer),
"correct_answer": validation.Validate(&req.Data.Attributes.CorrectAnswer),
"starts_at": validation.Validate(&req.Data.Attributes.StartsAt),
"options": validation.Validate(&req.Data.Attributes.Options),
"reward": validation.Validate(&req.Data.Attributes.Reward),
"title": validation.Validate(&req.Data.Attributes.Title),
"data/id": validation.Validate(&req.Data.ID, validation.Required),
"data/type": validation.Validate(&req.Data.Type, validation.Required),
"data/attributes": validation.Validate(&req.Data.Attributes, validation.Required),
}.Filter()
}

0 comments on commit 543a036

Please sign in to comment.