Spaces:
Sleeping
Sleeping
fix(assistants): assistant sorting
Browse filesthe sorting was returning duplicate assistants occasionally, this should be fixed
src/lib/server/database.ts
CHANGED
|
@@ -202,6 +202,9 @@ export class Database {
|
|
| 202 |
assistants.createIndex({ modelId: 1, userCount: -1 }).catch((e) => logger.error(e));
|
| 203 |
assistants.createIndex({ searchTokens: 1 }).catch((e) => logger.error(e));
|
| 204 |
assistants.createIndex({ last24HoursCount: 1 }).catch((e) => logger.error(e));
|
|
|
|
|
|
|
|
|
|
| 205 |
assistantStats
|
| 206 |
// Order of keys is important for the queries
|
| 207 |
.createIndex({ "date.span": 1, "date.at": 1, assistantId: 1 }, { unique: true })
|
|
|
|
| 202 |
assistants.createIndex({ modelId: 1, userCount: -1 }).catch((e) => logger.error(e));
|
| 203 |
assistants.createIndex({ searchTokens: 1 }).catch((e) => logger.error(e));
|
| 204 |
assistants.createIndex({ last24HoursCount: 1 }).catch((e) => logger.error(e));
|
| 205 |
+
assistants
|
| 206 |
+
.createIndex({ last24HoursUseCount: -1, useCount: -1, _id: 1 })
|
| 207 |
+
.catch((e) => logger.error(e));
|
| 208 |
assistantStats
|
| 209 |
// Order of keys is important for the queries
|
| 210 |
.createIndex({ "date.span": 1, "date.at": 1, assistantId: 1 }, { unique: true })
|
src/routes/assistants/+page.server.ts
CHANGED
|
@@ -57,6 +57,7 @@ export const load = async ({ url, locals }) => {
|
|
| 57 |
.sort({
|
| 58 |
...(sort === SortKey.TRENDING && { last24HoursUseCount: -1 }),
|
| 59 |
useCount: -1,
|
|
|
|
| 60 |
})
|
| 61 |
.limit(NUM_PER_PAGE)
|
| 62 |
.toArray();
|
|
|
|
| 57 |
.sort({
|
| 58 |
...(sort === SortKey.TRENDING && { last24HoursUseCount: -1 }),
|
| 59 |
useCount: -1,
|
| 60 |
+
_id: 1,
|
| 61 |
})
|
| 62 |
.limit(NUM_PER_PAGE)
|
| 63 |
.toArray();
|