the browser-facing portion of osu!
at master 42 lines 929 B view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Libraries\Search; 7 8use App\Libraries\Elasticsearch\SearchParams; 9 10class UserSearchParams extends SearchParams 11{ 12 const VALID_SORT_FIELDS = ['relevance', 'username']; 13 const DEFAULT_SORT_FIELD = 'relevance'; 14 15 // all public because lazy. 16 17 public $recentOnly = false; 18 19 public $sortField = 'relevance'; 20 public $sortOrder = 'desc'; 21 22 /** {@inheritdoc} */ 23 public $size = 20; 24 25 public static function defaultSortOrder(string $field) 26 { 27 switch ($field) { 28 case 'username': 29 return 'asc'; 30 default: 31 return 'desc'; 32 } 33 } 34 35 /** 36 * {@inheritdoc} 37 */ 38 public function isCacheable(): bool 39 { 40 return false; 41 } 42}