More unit tests and html coverage report

also fixes a limit bug on listquery
This commit is contained in:
Jamie Curnow
2023-07-27 12:38:35 +10:00
parent e4e70ae6be
commit 9faa36315f
19 changed files with 479 additions and 183 deletions

View File

@ -19,11 +19,11 @@ func ScopeOffsetLimit(pageInfo *model.PageInfo) func(db *gorm.DB) *gorm.DB {
}
}
func ScopeOrderBy(pageInfo *model.PageInfo, defaultSort model.Sort) func(db *gorm.DB) *gorm.DB {
func ScopeOrderBy(sort []model.Sort, defaultSort model.Sort) func(db *gorm.DB) *gorm.DB {
return func(db *gorm.DB) *gorm.DB {
if pageInfo.Sort != nil {
if sort != nil {
// Sort by items in slice
return db.Order(sortToOrderString(pageInfo.Sort))
return db.Order(sortToOrderString(sort))
} else if defaultSort.Field != "" {
// Default to this sort
str := defaultSort.Field