Skip to content

Commit 4875f63

Browse files
committed
Merge branch '2.2.x' for 2.2.1 release
2 parents fa9d612 + 8f64477 commit 4875f63

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

services/log-cleanup.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const getDatabase = require('./mongodb');
1+
const mongodb = require('./mongodb');
22
const config = require('../config');
33

44
/**
@@ -7,15 +7,15 @@ const config = require('../config');
77
*/
88
async function setupLogRetention() {
99
try {
10-
const db = await getDatabase();
10+
const db = mongodb.get('rsscloud');
1111
const collection = db.collection('events');
1212

1313
const retentionSeconds = config.logRetentionHours * 3600;
1414

15-
// Create TTL index on the when field (log timestamp)
16-
// MongoDB will automatically delete documents when 'when' is older than retentionSeconds
15+
// Create TTL index on the time field (log timestamp)
16+
// MongoDB will automatically delete documents when 'time' is older than retentionSeconds
1717
await collection.createIndex(
18-
{ when: 1 },
18+
{ time: 1 },
1919
{
2020
expireAfterSeconds: retentionSeconds,
2121
name: 'log_retention_ttl'
@@ -35,14 +35,14 @@ async function setupLogRetention() {
3535
*/
3636
async function removeExpiredLogs() {
3737
try {
38-
const db = await getDatabase();
38+
const db = mongodb.get('rsscloud');
3939
const collection = db.collection('events');
4040

4141
const cutoffDate = new Date();
4242
cutoffDate.setHours(cutoffDate.getHours() - config.logRetentionHours);
4343

4444
const result = await collection.deleteMany({
45-
when: { $lt: cutoffDate }
45+
time: { $lt: cutoffDate }
4646
});
4747

4848
console.log(`Removed ${result.deletedCount} expired log entries older than ${cutoffDate.toISOString()}`);

services/remove-expired-subscriptions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const getDatabase = require('./mongodb');
1+
const mongodb = require('./mongodb');
22
const getDayjs = require('./dayjs-wrapper');
33
const config = require('../config');
44

@@ -8,7 +8,7 @@ const config = require('../config');
88
*/
99
async function removeExpiredSubscriptions() {
1010
try {
11-
const db = await getDatabase();
11+
const db = mongodb.get('rsscloud');
1212
const dayjs = await getDayjs();
1313
const collection = db.collection('subscriptions');
1414

0 commit comments

Comments
 (0)