Spaces:
Paused
Paused
fix: assistant search
Browse files
src/routes/assistants/+page.server.ts
CHANGED
|
@@ -46,16 +46,18 @@ export const load = async ({ url, locals }) => {
|
|
| 46 |
}
|
| 47 |
}
|
| 48 |
|
|
|
|
| 49 |
// fetch the top assistants sorted by user count from biggest to smallest.
|
| 50 |
// filter by model too if modelId is provided or query if query is provided
|
| 51 |
-
//
|
| 52 |
const filter: Filter<Assistant> = {
|
| 53 |
...(modelId && { modelId }),
|
| 54 |
...(user && { createdById: user._id }),
|
| 55 |
...(query && { searchTokens: { $all: generateQueryTokens(query) } }),
|
| 56 |
-
...(
|
| 57 |
...shouldBeFeatured,
|
| 58 |
};
|
|
|
|
| 59 |
const assistants = await Database.getInstance()
|
| 60 |
.getCollections()
|
| 61 |
.assistants.find(filter)
|
|
|
|
| 46 |
}
|
| 47 |
}
|
| 48 |
|
| 49 |
+
const noSpecificSearch = !user && !query;
|
| 50 |
// fetch the top assistants sorted by user count from biggest to smallest.
|
| 51 |
// filter by model too if modelId is provided or query if query is provided
|
| 52 |
+
// only show assistants that have been used by more than 5 users if no specific search is made
|
| 53 |
const filter: Filter<Assistant> = {
|
| 54 |
...(modelId && { modelId }),
|
| 55 |
...(user && { createdById: user._id }),
|
| 56 |
...(query && { searchTokens: { $all: generateQueryTokens(query) } }),
|
| 57 |
+
...(noSpecificSearch && { userCount: { $gte: 5 } }),
|
| 58 |
...shouldBeFeatured,
|
| 59 |
};
|
| 60 |
+
|
| 61 |
const assistants = await Database.getInstance()
|
| 62 |
.getCollections()
|
| 63 |
.assistants.find(filter)
|