export data from specific date

This commit is contained in:
2026-05-18 17:48:00 +03:00
parent 0369a40ad9
commit 1cca6d28ca
2 changed files with 8 additions and 2 deletions

View File

@@ -24,6 +24,10 @@ module.exports = {
channels: {
mergeDiscussionIntoParent: true,
},
posts: {
// Экспортировать посты только начиная с этой даты (ISO 8601). Если не задано - экспортируются все посты.
fromDate: '2026-05-18T00:00:00.000Z',
},
user: {
globalRoleMap: {
admin: 'system_admin',

View File

@@ -16,8 +16,10 @@ module.exports = async function (context) {
let written = 0
let memReplyIds = {}
const total = await collection.count()
const cursor = collection.find()
const fromDate = _.get(context, 'config.define.posts.fromDate')
const query = fromDate ? { ts: { $gte: new Date(fromDate) } } : {}
const total = await collection.count(query)
const cursor = collection.find(query)
while (await cursor.hasNext()) {
const result = await cursor.next()
let posts = await collectPostData(context, result, memReplyIds, false)