Spaces:
Sleeping
Sleeping
coyotte508
commited on
Commit
·
a28b199
1
Parent(s):
1d46bd1
mongodb index creation
Browse files
src/lib/jobs/refresh-conversation-stats.ts
CHANGED
|
@@ -33,7 +33,9 @@ async function computeStats(params: {
|
|
| 33 |
span: ConversationStats["date"]["span"];
|
| 34 |
type: ConversationStats["type"];
|
| 35 |
}) {
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
return;
|
| 38 |
}
|
| 39 |
|
|
|
|
| 33 |
span: ConversationStats["date"]["span"];
|
| 34 |
type: ConversationStats["type"];
|
| 35 |
}) {
|
| 36 |
+
const indexes = await collections.semaphores.listIndexes().toArray();
|
| 37 |
+
if (indexes.length <= 2) {
|
| 38 |
+
logger.info("Indexes not created, skipping stats computation");
|
| 39 |
return;
|
| 40 |
}
|
| 41 |
|
src/lib/server/database.ts
CHANGED
|
@@ -66,9 +66,11 @@ export class Database {
|
|
| 66 |
}
|
| 67 |
|
| 68 |
try {
|
|
|
|
| 69 |
await this.client.connect();
|
|
|
|
| 70 |
this.client.db(config.MONGODB_DB_NAME + (import.meta.env.MODE === "test" ? "-test" : ""));
|
| 71 |
-
|
| 72 |
} catch (err) {
|
| 73 |
logger.error(err, "Connection error");
|
| 74 |
process.exit(1);
|
|
|
|
| 66 |
}
|
| 67 |
|
| 68 |
try {
|
| 69 |
+
logger.info("Connecting to database");
|
| 70 |
await this.client.connect();
|
| 71 |
+
logger.info("Connected to database");
|
| 72 |
this.client.db(config.MONGODB_DB_NAME + (import.meta.env.MODE === "test" ? "-test" : ""));
|
| 73 |
+
await this.initDatabase();
|
| 74 |
} catch (err) {
|
| 75 |
logger.error(err, "Connection error");
|
| 76 |
process.exit(1);
|