Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于alter-gateway中model/alert.go查询已经有的报警信息 时,为什么只取queryres[0]第一条信息? #95

Open
sunism opened this issue Feb 4, 2021 · 2 comments

Comments

@sunism
Copy link

sunism commented Feb 4, 2021

_, err := Ormer().Raw("SELECT id,status FROM alert WHERE rule_id =? AND labels=? AND fired_at=?", a.ruleId, a.label, a.firedAt).QueryRows(&queryres)
if err == nil {
if len(queryres) > 0 {
// alert has been triggered by post requests before
------> if queryres[0].Status != 0 { //为什么只取第一条查询到的信息,有多条信息如何处理

@sunism
Copy link
Author

sunism commented Feb 4, 2021

_, err := Ormer().Raw("SELECT id,status FROM alert WHERE rule_id =? AND labels=? AND fired_at=?", a.ruleId, a.label, a.firedAt).QueryRows(&queryres),
按照这种查询方式,rule_id, labels,和 fired_at都要同时满足的情况,只可能查出一条数据吧,为什么queryres要用数组呢

@jayryu
Copy link
Collaborator

jayryu commented Feb 10, 2021

_, err := Ormer().Raw("SELECT id,status FROM alert WHERE rule_id =? AND labels=? AND fired_at=?", a.ruleId, a.label, a.firedAt).QueryRows(&queryres),
按照这种查询方式,rule_id, labels,和 fired_at都要同时满足的情况,只可能查出一条数据吧,为什么queryres要用数组呢
你说的对,这里就是个人习惯用数组了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants