Make first WebUI random page stick

This commit is contained in:
Deluan 2024-05-19 12:35:30 -04:00
parent 653b4d97f9
commit 3977ef6e0f
6 changed files with 75 additions and 21 deletions

View file

@ -144,9 +144,17 @@ func (r sqlRepository) seededRandomSort() string {
}
func (r sqlRepository) resetSeededRandom(options []model.QueryOptions) {
if len(options) > 0 && options[0].Offset == 0 && options[0].Sort == "random" {
u, _ := request.UserFrom(r.ctx)
hasher.Reseed(r.tableName + u.ID)
if len(options) == 0 || options[0].Sort != "random" {
return
}
if options[0].Seed != "" {
hasher.SetSeed(r.tableName+userId(r.ctx), options[0].Seed)
return
}
if options[0].Offset == 0 {
hasher.Reseed(r.tableName + userId(r.ctx))
}
}

View file

@ -42,6 +42,10 @@ func (r sqlRestful) parseRestOptions(options ...rest.QueryOptions) model.QueryOp
qo.Order = strings.ToLower(options[0].Order)
qo.Max = options[0].Max
qo.Offset = options[0].Offset
if seed, ok := options[0].Filters["seed"].(string); ok {
qo.Seed = seed
delete(options[0].Filters, "seed")
}
qo.Filters = r.parseRestFilters(options[0])
}
return qo