fix postgreSQL count fail (#1184)
This commit is contained in:
parent
c81fc87d4e
commit
b1a7ffb92f
1 changed files with 8 additions and 5 deletions
|
@ -753,17 +753,20 @@ func (c *Client) QueryAlertWithFilter(filter map[string][]string) ([]*ent.Alert,
|
|||
WithEvents().
|
||||
WithMetas().
|
||||
WithOwner()
|
||||
if sort == "ASC" {
|
||||
alerts = alerts.Order(ent.Asc(alert.FieldCreatedAt))
|
||||
} else {
|
||||
alerts = alerts.Order(ent.Desc(alert.FieldCreatedAt))
|
||||
}
|
||||
|
||||
if limit == 0 {
|
||||
limit, err = alerts.Count(c.CTX)
|
||||
if err != nil {
|
||||
return []*ent.Alert{}, fmt.Errorf("unable to count nb alerts: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
if sort == "ASC" {
|
||||
alerts = alerts.Order(ent.Asc(alert.FieldCreatedAt))
|
||||
} else {
|
||||
alerts = alerts.Order(ent.Desc(alert.FieldCreatedAt))
|
||||
}
|
||||
|
||||
result, err := alerts.Limit(paginationSize).Offset(offset).All(c.CTX)
|
||||
if err != nil {
|
||||
return []*ent.Alert{}, errors.Wrapf(QueryFail, "pagination size: %d, offset: %d: %s", paginationSize, offset, err)
|
||||
|
|
Loading…
Add table
Reference in a new issue