Node.js based forum software built for the modern web
fix: add upgrade script for notifications
Barış Soner Uşaklı6c3ff86bcfcd
diff --git a/src/upgrades/3.5.0/notification_translations.js b/src/upgrades/3.5.0/notification_translations.jsnew file mode 100644index 0000000000..321243e794--- /dev/null+++ b/src/upgrades/3.5.0/notification_translations.js@@ -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,+ });+ },+};