Skip to content

Commit

Permalink
Fix contest messages and solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
udovin committed Apr 23, 2024
1 parent 6b3fa2e commit dfc7302
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions internal/api/contest_messages.go
Expand Up @@ -77,7 +77,7 @@ func (f *CreateContestMessageForm) Update(
) error {
errors := errorFields{}
if f.ParentID == nil {
if len(f.Title) < 4 {
if len(f.Title) < 2 {
errors["title"] = errorField{
Message: localize(c, "Title is too short."),
}
Expand All @@ -89,7 +89,7 @@ func (f *CreateContestMessageForm) Update(
} else {
f.Title = ""
}
if len(f.Description) < 4 {
if len(f.Description) < 2 {
errors["description"] = errorField{
Message: localize(c, "Description is too short."),
}
Expand Down Expand Up @@ -167,7 +167,7 @@ func (f SubmitContestQuestionForm) Update(
c echo.Context, o *models.ContestMessage,
) error {
errors := errorFields{}
if len(f.Title) < 4 {
if len(f.Title) < 2 {
errors["title"] = errorField{
Message: localize(c, "Title is too short."),
}
Expand Down
14 changes: 9 additions & 5 deletions internal/api/contests.go
Expand Up @@ -1032,10 +1032,11 @@ type ContestSolutions struct {
}

type contestSolutionsFilter struct {
ProblemID int64 `query:"problem_id"`
Verdict models.Verdict `query:"verdict"`
BeginID int64 `query:"begin_id"`
Limit int `query:"limit"`
ProblemID int64 `query:"problem_id"`
ParticipantID int64 `query:"participant_id"`
Verdict models.Verdict `query:"verdict"`
BeginID int64 `query:"begin_id"`
Limit int `query:"limit"`
}

func (f *contestSolutionsFilter) Parse(c echo.Context) error {
Expand All @@ -1059,6 +1060,9 @@ func (f *contestSolutionsFilter) Filter(solution models.ContestSolution) bool {
if f.ProblemID != 0 && solution.ProblemID != f.ProblemID {
return false
}
if f.ParticipantID != 0 && solution.ParticipantID != f.ParticipantID {
return false
}
if f.BeginID != 0 && solution.ID > f.BeginID {
return false
}
Expand All @@ -1071,7 +1075,7 @@ func (v *View) observeContestSolutions(c echo.Context) error {
if !ok {
return fmt.Errorf("contest not extracted")
}
filter := contestSolutionsFilter{Limit: 250}
filter := contestSolutionsFilter{Limit: 50}
if err := filter.Parse(c); err != nil {
c.Logger().Warn(err)
return err
Expand Down

0 comments on commit dfc7302

Please sign in to comment.