Skip to content

Commit fd227b7

Browse files
committed
Fixes for review
1 parent 34cdb6f commit fd227b7

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

clients/tsapi/masterstatus/master_status.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ func (s *MasterStatus) runUpdateThread() {
4545

4646
t := time.Tick(s.statusUpdateInterval)
4747
for {
48+
s.updateStatus()
4849
select {
4950
case <-t:
50-
s.updateStatus()
5151
}
5252
}
5353
}
@@ -122,9 +122,7 @@ type SubmissionsFilter struct {
122122
func (s *MasterStatus) GetSubmissions(ctx context.Context, filter *SubmissionsFilter) ([]SubmissionInList, error) {
123123
request := s.base.DB.
124124
WithContext(ctx).
125-
Model(&models.Submission{}).
126-
Limit(filter.Count).
127-
Offset((filter.Page - 1) * filter.Count)
125+
Model(&models.Submission{})
128126

129127
if filter.ProblemID != nil {
130128
request = request.Where("problem_id=?", *filter.ProblemID)
@@ -139,6 +137,8 @@ func (s *MasterStatus) GetSubmissions(ctx context.Context, filter *SubmissionsFi
139137

140138
err := request.
141139
Order("id desc").
140+
Limit(filter.Count).
141+
Offset((filter.Page - 1) * filter.Count).
142142
Find(&submissions).
143143
Error
144144

clients/tsapi/problem.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,20 @@ func (h *Handler) getProblems(c *gin.Context) {
2929
return
3030
}
3131
var problems []problemInList
32+
if filter.Count <= 0 {
33+
respError(c, http.StatusBadRequest, "Count should be positive number")
34+
return
35+
}
36+
if filter.Page <= 0 {
37+
respError(c, http.StatusBadRequest, "Page should be positive number")
38+
return
39+
}
3240
err := h.base.DB.
3341
WithContext(c).
3442
Model(&models.Problem{}).
43+
Order("id desc").
3544
Limit(filter.Count).
3645
Offset((filter.Page - 1) * filter.Count).
37-
Order("id desc").
3846
Find(&problems).
3947
Error
4048
if err != nil {

invoker/threads_executor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func (e *threadsExecutor[Value]) stop() {
4747

4848
if e.closed {
4949
logger.Warn("%s threads are already stopped, calling stop twice", e.name)
50+
return
5051
}
5152
e.closed = true
5253
e.cond.Broadcast()

0 commit comments

Comments
 (0)