GetStoredCdrs.Count temporary fix until gorm analyses our reported issue

This commit is contained in:
DanB
2015-02-04 13:56:33 +01:00
parent 490bd9d573
commit afb8aae211
4 changed files with 41 additions and 44 deletions

View File

@@ -955,13 +955,18 @@ func (self *SQLStorage) GetStoredCdrs(qryFltr *utils.CdrsFilter) ([]*utils.Store
if qryFltr.PaginatorLimit != 0 {
q = q.Limit(qryFltr.PaginatorLimit)
}
/* ToDo: Fix as soon as issue on Gorm analyzed: https://github.com/jinzhu/gorm/issues/354
if qryFltr.Count {
var cnt int64
fmt.Printf("Rows is: %+v\n", rows)
//fmt.Printf("Counting, got count: %+v\n", q.Count())
if err := q.Count(&cnt).Error; err != nil {
fmt.Printf("Counting, got error %s", err.Error())
return nil, 0, err
}
return nil, cnt, nil
}
*/
// Execute query
rows, err := q.Rows()
if err != nil {
@@ -996,6 +1001,9 @@ func (self *SQLStorage) GetStoredCdrs(qryFltr *utils.CdrsFilter) ([]*utils.Store
}
cdrs = append(cdrs, storCdr)
}
if qryFltr.Count { // Emulate Count for now
return nil, int64(len(cdrs)), nil
}
return cdrs, 0, nil
}