Skip to content

Commit

Permalink
support ID filtering on indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenClontz committed Dec 12, 2024
1 parent 3cbe691 commit 19e3eed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions packages/viewer/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ export const sentryIngest =

// Used for Fuse searches
export const searchWeights = {
id: 3,
name: 1,
aliases: 0.7,
description: 0.3,
}
export const searchKeys = [
{ name: 'id', weight: 3, getFn: (s: any) => `${s.id}` },
{ name: 'name', weight: 1 },
{ name: 'aliases', weight: 0.7 },
{ name: 'description', weight: 0.3 },
{ name: 'id', weight: searchWeights.id, getFn: (s: any) => `${s.id}` },
{ name: 'name', weight: searchWeights.name },
{ name: 'aliases', weight: searchWeights.aliases },
{ name: 'description', weight: searchWeights.description },
]
export const searchThreshold = 0.3
3 changes: 2 additions & 1 deletion packages/viewer/src/stores/list.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Fuse from 'fuse.js'
import { type Readable, type Writable, derived, writable } from 'svelte/store'

import { searchThreshold } from '@/constants'
import { searchKeys, searchThreshold } from '@/constants'

import * as sort from './sort'

Expand All @@ -25,6 +25,7 @@ export default function list<T>(
const keys = Object.entries(weights).map(([name, weight]) => ({
name,
weight: (weight as number) || 0,
getFn: searchKeys.find(o=>o.name === name)?.getFn
}))
const index = derived(
collection,
Expand Down

0 comments on commit 19e3eed

Please sign in to comment.