首页增加比例筛选并优化排序
This commit is contained in:
@@ -2,6 +2,7 @@ package listing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -117,7 +118,10 @@ func canListPublicWithSQL(query PublicListQuery) bool {
|
||||
if len(query.SkinGroup) > 0 || len(query.SkinName) > 0 || len(query.ResourceRanges) > 0 {
|
||||
return false
|
||||
}
|
||||
if query.MinCoin != nil || query.MaxCoin != nil || query.MinPrice != nil || query.MaxPrice != nil {
|
||||
if query.MinCoin != nil || query.MaxCoin != nil || query.MinRatio != nil || query.MaxRatio != nil {
|
||||
return false
|
||||
}
|
||||
if query.MinPrice != nil || query.MaxPrice != nil {
|
||||
return false
|
||||
}
|
||||
if query.MinDeposit != nil || query.MaxDeposit != nil || query.MinTotal != nil || query.MaxTotal != nil {
|
||||
@@ -142,11 +146,18 @@ func applyPublicSQLSort(db *gorm.DB, sortKey string) *gorm.DB {
|
||||
return db.Order("l.price_cent DESC, l.published_at DESC, l.id DESC")
|
||||
case "coinDesc":
|
||||
return db.Order("a.haf_coin_amount DESC, l.published_at DESC, l.id DESC")
|
||||
default:
|
||||
case "published":
|
||||
return db.Order("l.published_at DESC, l.id DESC")
|
||||
default:
|
||||
return db.Order(fmt.Sprintf("((l.id * 1103515245 + %d) %% 2147483647) ASC, l.id ASC", publicShuffleSeed()))
|
||||
}
|
||||
}
|
||||
|
||||
func publicShuffleSeed() int64 {
|
||||
now := time.Now().UTC()
|
||||
return int64(now.Year()*366 + now.YearDay())
|
||||
}
|
||||
|
||||
func (r *Repository) publicZoneCountsCached(ctx context.Context) (map[string]int64, error) {
|
||||
now := time.Now()
|
||||
r.publicZoneCountsMu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user