@tiledesk/tiledesk-server 2.19.6 → 2.19.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/package.json +1 -1
- package/pubmodules/events/event.js +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
🚀 IN PRODUCTION 🚀
|
|
6
6
|
(https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
|
|
7
7
|
|
|
8
|
+
# 2.19.6
|
|
9
|
+
- Added TTL for events collection
|
|
10
|
+
|
|
8
11
|
# 2.19.6
|
|
9
12
|
- Improved management of answered and unanswered questions, duration and token consumption
|
|
10
13
|
- Improved namespace embedding management
|
package/package.json
CHANGED
|
@@ -2,6 +2,17 @@ var mongoose = require('mongoose');
|
|
|
2
2
|
var Schema = mongoose.Schema;
|
|
3
3
|
var winston = require('../../config/winston');
|
|
4
4
|
|
|
5
|
+
const DEFAULT_EVENTS_TTL_SEC = 3600;
|
|
6
|
+
|
|
7
|
+
function ttlSecondsFromEnv(raw, fallbackSec) {
|
|
8
|
+
if (raw == null || String(raw).trim() === '') return fallbackSec;
|
|
9
|
+
const n = Number(raw);
|
|
10
|
+
return Number.isFinite(n) && n >= 0 ? n : fallbackSec;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const eventsTtlSeconds = ttlSecondsFromEnv(process.env.EVENTS_TTL_SECONDS, DEFAULT_EVENTS_TTL_SEC);
|
|
14
|
+
winston.info('Events TTL seconds: ' + eventsTtlSeconds);
|
|
15
|
+
|
|
5
16
|
|
|
6
17
|
var EventSchema = new Schema({
|
|
7
18
|
|
|
@@ -47,6 +58,7 @@ var EventSchema = new Schema({
|
|
|
47
58
|
);
|
|
48
59
|
|
|
49
60
|
EventSchema.index({ id_project: 1, name: 1, createdAt: -1 });
|
|
61
|
+
EventSchema.index({ createdAt: 1 }, { expireAfterSeconds: eventsTtlSeconds });
|
|
50
62
|
|
|
51
63
|
var event = mongoose.model('event', EventSchema);
|
|
52
64
|
|