mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: add upgrade script for notifications
This commit is contained in:
32
src/upgrades/3.5.0/notification_translations.js
Normal file
32
src/upgrades/3.5.0/notification_translations.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/* eslint-disable no-await-in-loop */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const db = require('../../database');
|
||||||
|
const batch = require('../../batch');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'Update translation keys in notification bodyShort',
|
||||||
|
timestamp: Date.UTC(2023, 6, 27),
|
||||||
|
method: async function () {
|
||||||
|
const { progress } = this;
|
||||||
|
|
||||||
|
await batch.processSortedSet(`notifications`, async (nids) => {
|
||||||
|
const notifData = await db.getObjects(nids.map(nid => `notifications:${nid}`));
|
||||||
|
notifData.forEach((n) => {
|
||||||
|
if (n && n.bodyShort) {
|
||||||
|
n.bodyShort = n.bodyShort.replace(/_/g, '-');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const bulkSet = notifData.map(
|
||||||
|
n => [`notifications:${n.nid}`, { bodyShort: n.bodyShort }]
|
||||||
|
);
|
||||||
|
|
||||||
|
await db.setObjectBulk(bulkSet);
|
||||||
|
}, {
|
||||||
|
batch: 500,
|
||||||
|
progress: progress,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user