Remove page normalizers
Unneeded.
This commit is contained in:
@@ -207,8 +207,6 @@ func (svc record) Report(namespaceID, moduleID uint64, metrics, dimensions, filt
|
||||
}
|
||||
|
||||
func (svc record) Find(filter types.RecordFilter) (set types.RecordSet, f types.RecordFilter, err error) {
|
||||
filter.PageFilter.NormalizePerPageWithDefaults()
|
||||
|
||||
var m *types.Module
|
||||
if m, err = svc.loadModule(filter.NamespaceID, filter.ModuleID); err != nil {
|
||||
return
|
||||
|
||||
@@ -24,15 +24,3 @@ func Paging(page, perPage uint) PageFilter {
|
||||
PerPage: perPage,
|
||||
}
|
||||
}
|
||||
|
||||
func (pf *PageFilter) NormalizePerPage(min, max, def uint) {
|
||||
pf.PerPage = NormalizePerPage(pf.PerPage, min, max, def)
|
||||
}
|
||||
|
||||
func (pf *PageFilter) NormalizePerPageWithDefaults() {
|
||||
pf.PerPage = NormalizePerPage(pf.PerPage, PER_PAGE_MIN, PER_PAGE_MAX, PER_PAGE_DEFAULT)
|
||||
}
|
||||
|
||||
func (pf *PageFilter) NormalizePerPageNoMax() {
|
||||
pf.PerPage = NormalizePerPage(pf.PerPage, PER_PAGE_MIN, 0, PER_PAGE_DEFAULT)
|
||||
}
|
||||
|
||||
@@ -71,23 +71,6 @@ func FetchAll(db *factory.DB, q squirrel.Sqlizer, set interface{}) error {
|
||||
}
|
||||
}
|
||||
|
||||
// NormalizePerPage normalize page number
|
||||
func NormalizePerPage(val, min, max, def uint) uint {
|
||||
if val == 0 {
|
||||
return def
|
||||
}
|
||||
|
||||
if max > 0 && val > max {
|
||||
return max
|
||||
}
|
||||
|
||||
if min > 0 && val < min {
|
||||
return min
|
||||
}
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
// IsFound helps with one-row results
|
||||
func IsFound(err error, valid bool, nerr error) error {
|
||||
if err != nil {
|
||||
|
||||
@@ -49,8 +49,6 @@ func Reminder(ctx context.Context) ReminderService {
|
||||
}
|
||||
|
||||
func (svc reminder) Find(ctx context.Context, f types.ReminderFilter) (types.ReminderSet, types.ReminderFilter, error) {
|
||||
f.PageFilter.NormalizePerPageNoMax()
|
||||
|
||||
rr, f, err := svc.reminder.Find(f)
|
||||
if err != nil {
|
||||
return nil, f, err
|
||||
|
||||
Reference in New Issue
Block a user