Skip to content

Commit

Permalink
Merge pull request open-falcon#364 from bonfy/master
Browse files Browse the repository at this point in the history
[alarm_events_controller]fix limit params of AlarmLists api
  • Loading branch information
laiwei authored Jan 24, 2018
2 parents ca233fa + 65c84d1 commit 1b2175d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion modules/api/app/controller/alarm/alarm_events_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,13 @@ func AlarmLists(c *gin.Context) {
if inputs.Limit >= 50 {
inputs.Limit = 50
}
perparedSql = fmt.Sprintf("select * from %s %s order by timestamp DESC limit %d,%d", f.TableName(), filterCollector, inputs.Page, inputs.Limit)

// if page stands for step page
// {"page":0} for actual page 1
// step = page * limit
step := inputs.Page * inputs.Limit

perparedSql = fmt.Sprintf("select * from %s %s order by timestamp DESC limit %d,%d", f.TableName(), filterCollector, step, inputs.Limit)
}
db.Alarm.Raw(perparedSql).Find(&cevens)
h.JSONR(c, cevens)
Expand Down

0 comments on commit 1b2175d

Please sign in to comment.