diff --git a/web/pages/contract-search-firestore.tsx b/web/pages/contract-search-firestore.tsx
index 4691030c..09c9a321 100644
--- a/web/pages/contract-search-firestore.tsx
+++ b/web/pages/contract-search-firestore.tsx
@@ -8,6 +8,8 @@ import {
usePersistentState,
urlParamStore,
} from 'web/hooks/use-persistent-state'
+import { getProbability } from 'common/calculate'
+import { BinaryContract, PseudoNumericContract } from 'common/contract'
const MAX_CONTRACTS_RENDERED = 100
@@ -18,13 +20,17 @@ export default function ContractSearchFirestore(props: {
excludeContractIds?: string[]
groupSlug?: string
}
+ defaultSort?: string
}) {
const { additionalFilter } = props
const contracts = useContracts()
const router = useRouter()
const store = urlParamStore(router)
const [query, setQuery] = usePersistentState('', { key: 'q', store })
- const [sort, setSort] = usePersistentState('score', { key: 'sort', store })
+ const [sort, setSort] = usePersistentState(props.defaultSort ?? 'score', {
+ key: 'sort',
+ store,
+ })
let matches = (contracts ?? []).filter((c) =>
searchInAny(
@@ -51,6 +57,10 @@ export default function ContractSearchFirestore(props: {
// Use lodash for stable sort, so previous sort breaks all ties.
matches = sortBy(matches, ({ volume7Days }) => -1 * volume7Days)
matches = sortBy(matches, ({ volume24Hours }) => -1 * volume24Hours)
+ } else if (sort === 'highest-percent') {
+ matches = sortBy(matches, (c) =>
+ getProbability(c as BinaryContract | PseudoNumericContract)
+ ).reverse()
}
if (additionalFilter) {
@@ -99,6 +109,7 @@ export default function ContractSearchFirestore(props: {
value={sort}
onChange={(e) => setSort(e.target.value)}
>
+
diff --git a/web/pages/group/[...slugs]/index.tsx b/web/pages/group/[...slugs]/index.tsx
index 4626aa77..c7bccbfe 100644
--- a/web/pages/group/[...slugs]/index.tsx
+++ b/web/pages/group/[...slugs]/index.tsx
@@ -52,6 +52,8 @@ import { Post } from 'common/post'
import { Spacer } from 'web/components/layout/spacer'
import { usePost } from 'web/hooks/use-post'
import { useAdmin } from 'web/hooks/use-admin'
+import { isTournament } from 'web/pages/tournaments'
+import ContractSearchFirestore from 'web/pages/contract-search-firestore'
export const getStaticProps = fromPropz(getStaticPropz)
export async function getStaticPropz(props: { params: { slugs: string[] } }) {
@@ -220,7 +222,13 @@ export default function GroupPage(props: {
)
- const questionsTab = (
+ // Use Firestore search for Tournament groups, so they can sort by highest
+ const questionsTab = isTournament(group.id) ? (
+
+ ) : (
t.groupId).includes(groupId)
+}
+
export async function getStaticProps() {
const groupIds = tourneys
.map((data) => data.groupId)