🗃️ Create index on users.username (#819)
Browse files* 🗃️ Create index on `users.username`
* 🗃️ Do not do db.assistants.find({modelId: {$exists: true}) since it's always true
src/lib/server/database.ts
CHANGED
|
@@ -70,6 +70,8 @@ client.on("open", () => {
|
|
| 70 |
settings.createIndex({ assistants: 1 }).catch(console.error);
|
| 71 |
users.createIndex({ hfUserId: 1 }, { unique: true }).catch(console.error);
|
| 72 |
users.createIndex({ sessionId: 1 }, { unique: true, sparse: true }).catch(console.error);
|
|
|
|
|
|
|
| 73 |
messageEvents.createIndex({ createdAt: 1 }, { expireAfterSeconds: 60 }).catch(console.error);
|
| 74 |
sessions.createIndex({ expiresAt: 1 }, { expireAfterSeconds: 0 }).catch(console.error);
|
| 75 |
sessions.createIndex({ sessionId: 1 }, { unique: true }).catch(console.error);
|
|
|
|
| 70 |
settings.createIndex({ assistants: 1 }).catch(console.error);
|
| 71 |
users.createIndex({ hfUserId: 1 }, { unique: true }).catch(console.error);
|
| 72 |
users.createIndex({ sessionId: 1 }, { unique: true, sparse: true }).catch(console.error);
|
| 73 |
+
// No unicity because due to renames & outdated info from oauth provider, there may be the same username on different users
|
| 74 |
+
users.createIndex({ username: 1 }).catch(console.error);
|
| 75 |
messageEvents.createIndex({ createdAt: 1 }, { expireAfterSeconds: 60 }).catch(console.error);
|
| 76 |
sessions.createIndex({ expiresAt: 1 }, { expireAfterSeconds: 0 }).catch(console.error);
|
| 77 |
sessions.createIndex({ sessionId: 1 }, { unique: true }).catch(console.error);
|
src/routes/assistants/+page.server.ts
CHANGED
|
@@ -26,7 +26,7 @@ export const load = async ({ url, locals }) => {
|
|
| 26 |
|
| 27 |
// fetch the top assistants sorted by user count from biggest to smallest, filter out all assistants with only 1 users. filter by model too if modelId is provided
|
| 28 |
const filter: Filter<Assistant> = {
|
| 29 |
-
modelId
|
| 30 |
...(!createdByCurrentUser && { userCount: { $gt: 1 } }),
|
| 31 |
...(createdByName ? { createdByName } : { featured: true }),
|
| 32 |
};
|
|
|
|
| 26 |
|
| 27 |
// fetch the top assistants sorted by user count from biggest to smallest, filter out all assistants with only 1 users. filter by model too if modelId is provided
|
| 28 |
const filter: Filter<Assistant> = {
|
| 29 |
+
...(modelId && { modelId }),
|
| 30 |
...(!createdByCurrentUser && { userCount: { $gt: 1 } }),
|
| 31 |
...(createdByName ? { createdByName } : { featured: true }),
|
| 32 |
};
|