From c17ef3659cc0d5b8e403a074ffa1804010916e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 17 Aug 2023 19:24:01 -0400 Subject: [PATCH 01/13] rewrite upgrade script so it doesnt error on alot of users https://community.nodebb.org/post/95433 --- src/upgrades/3.3.0/chat_room_refactor.js | 89 +++++++++++++++--------- 1 file changed, 55 insertions(+), 34 deletions(-) diff --git a/src/upgrades/3.3.0/chat_room_refactor.js b/src/upgrades/3.3.0/chat_room_refactor.js index 7c008a9764..0d9242b10c 100644 --- a/src/upgrades/3.3.0/chat_room_refactor.js +++ b/src/upgrades/3.3.0/chat_room_refactor.js @@ -1,8 +1,6 @@ 'use strict'; -const _ = require('lodash'); - const db = require('../../database'); const batch = require('../../batch'); @@ -18,46 +16,69 @@ module.exports = { for (let i = 1; i <= nextChatRoomId; i++) { allRoomIds.push(i); } - progress.total = allRoomIds.length; + progress.total = 0; + + // calculate user count and set progress.total + await batch.processArray(allRoomIds, async (roomIds) => { + await Promise.all(roomIds.map(async (roomId) => { + const userCount = await db.sortedSetCard(`chat:room:${roomId}:uids`); + await db.setObjectField(`chat:room:${roomId}`, 'userCount', userCount); + progress.total += userCount; + })); + }, { + batch: 500, + }); + await batch.processArray(allRoomIds, async (roomIds) => { - progress.incr(roomIds.length); - const [arrayOfUids, arrayOfRoomData] = await Promise.all([ - db.getSortedSetsMembers(roomIds.map(roomId => `chat:room:${roomId}:uids`)), - db.getObjects(roomIds.map(roomId => `chat:room:${roomId}`)), - ]); + const arrayOfRoomData = await db.getObjects(roomIds.map(roomId => `chat:room:${roomId}`)); await Promise.all(roomIds.map(async (roomId, index) => { - const uids = arrayOfUids[index]; const roomData = arrayOfRoomData[index]; - if (!uids.length && !roomData) { + if (!roomData) { return; } - if (roomData && roomData.owner && !uids.includes(String(roomData.owner))) { - uids.push(roomData.owner); - } - const userKeys = uids.map(uid => `uid:${uid}:chat:room:${roomId}:mids`); - const mids = await db.getSortedSetsMembers(userKeys); - const uniqMids = _.uniq(_.flatten(mids)); - let messageData = await db.getObjects(uniqMids.map(mid => `message:${mid}`)); - messageData.forEach((m, idx) => { - if (m) { - m.mid = parseInt(uniqMids[idx], 10); - } - }); - messageData = messageData.filter(Boolean); - const bulkSet = messageData.map( - msg => [`message:${msg.mid}`, { roomId: roomId }] - ); + const midsSeen = Object.create(null); + await batch.processSortedSet(`chat:room:${roomId}:uids`, async (uids) => { + for (const uid of uids) { + // eslint-disable-next-line no-await-in-loop + await batch.processSortedSet(`uid:${uid}:chat:room:${roomId}:mids`, async (mids) => { + const uniqMids = mids.filter(mid => !midsSeen.hasOwnProperty(mid)); + if (!uniqMids.length) { + return; + } + + let messageData = await db.getObjects(uniqMids.map(mid => `message:${mid}`)); + messageData.forEach((m, idx) => { + if (m) { + m.mid = parseInt(uniqMids[idx], 10); + } + }); + messageData = messageData.filter(Boolean); - await db.setObjectBulk(bulkSet); - await db.setObjectField(`chat:room:${roomId}`, 'userCount', uids.length); - await db.sortedSetAdd( - `chat:room:${roomId}:mids`, - messageData.map(m => m.timestamp), - messageData.map(m => m.mid), - ); - await db.deleteAll(userKeys); + const bulkSet = messageData.map( + msg => [`message:${msg.mid}`, { roomId: roomId }] + ); + + await db.setObjectBulk(bulkSet); + await db.sortedSetAdd( + `chat:room:${roomId}:mids`, + messageData.map(m => m.timestamp), + messageData.map(m => m.mid), + ); + uniqMids.forEach((mid) => { + midsSeen[mid] = 1; + }); + }, { + batch: 500, + }); + // eslint-disable-next-line no-await-in-loop + await db.deleteAll(`uid:${uid}:chat:room:${roomId}:mids`); + } + progress.incr(uids.length); + }, { + batch: 500, + }); })); }, { batch: 500, From f23b0b5bec892de6341fe9b1eece496042bc4cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 18 Aug 2023 11:59:42 -0400 Subject: [PATCH 02/13] fix: some more upgrade script fixes reduce parallel calls for psql --- src/upgrades/3.3.0/chat_message_mids.js | 5 +- src/upgrades/3.3.0/chat_room_online_zset.js | 2 +- src/upgrades/3.3.0/chat_room_refactor.js | 90 ++++++++++----------- 3 files changed, 47 insertions(+), 50 deletions(-) diff --git a/src/upgrades/3.3.0/chat_message_mids.js b/src/upgrades/3.3.0/chat_message_mids.js index d7f349ae98..36c331f1a8 100644 --- a/src/upgrades/3.3.0/chat_message_mids.js +++ b/src/upgrades/3.3.0/chat_message_mids.js @@ -1,3 +1,4 @@ +/* eslint-disable no-await-in-loop */ 'use strict'; @@ -13,7 +14,7 @@ module.exports = { progress.total = await db.sortedSetCard(`chat:rooms`); await batch.processSortedSet(`chat:rooms`, async (roomIds) => { progress.incr(roomIds.length); - await Promise.all(roomIds.map(async (roomId) => { + for (const roomId of roomIds) { await batch.processSortedSet(`chat:room:${roomId}:mids`, async (mids) => { let messageData = await db.getObjects(mids.map(mid => `message:${mid}`)); messageData.forEach((m, idx) => { @@ -36,7 +37,7 @@ module.exports = { }, { batch: 500, }); - })); + } }, { batch: 500, }); diff --git a/src/upgrades/3.3.0/chat_room_online_zset.js b/src/upgrades/3.3.0/chat_room_online_zset.js index 0a57076fa0..409d8bc0ef 100644 --- a/src/upgrades/3.3.0/chat_room_online_zset.js +++ b/src/upgrades/3.3.0/chat_room_online_zset.js @@ -26,7 +26,7 @@ module.exports = { }); await db.sortedSetAddBulk(bulkAdd); }, { - batch: 500, + batch: 100, }); }, }; diff --git a/src/upgrades/3.3.0/chat_room_refactor.js b/src/upgrades/3.3.0/chat_room_refactor.js index 0d9242b10c..252484d18f 100644 --- a/src/upgrades/3.3.0/chat_room_refactor.js +++ b/src/upgrades/3.3.0/chat_room_refactor.js @@ -1,10 +1,10 @@ -'use strict'; +/* eslint-disable no-await-in-loop */ +'use strict'; const db = require('../../database'); const batch = require('../../batch'); - module.exports = { name: 'Update chat messages to add roomId field', timestamp: Date.UTC(2023, 6, 2), @@ -31,55 +31,51 @@ module.exports = { await batch.processArray(allRoomIds, async (roomIds) => { const arrayOfRoomData = await db.getObjects(roomIds.map(roomId => `chat:room:${roomId}`)); - - await Promise.all(roomIds.map(async (roomId, index) => { - const roomData = arrayOfRoomData[index]; - if (!roomData) { - return; - } - - const midsSeen = Object.create(null); - await batch.processSortedSet(`chat:room:${roomId}:uids`, async (uids) => { - for (const uid of uids) { - // eslint-disable-next-line no-await-in-loop - await batch.processSortedSet(`uid:${uid}:chat:room:${roomId}:mids`, async (mids) => { - const uniqMids = mids.filter(mid => !midsSeen.hasOwnProperty(mid)); - if (!uniqMids.length) { - return; - } - - let messageData = await db.getObjects(uniqMids.map(mid => `message:${mid}`)); - messageData.forEach((m, idx) => { - if (m) { - m.mid = parseInt(uniqMids[idx], 10); + for (const roomData of arrayOfRoomData) { + if (roomData) { + const midsSeen = Object.create(null); + const { roomId } = roomData; + await batch.processSortedSet(`chat:room:${roomId}:uids`, async (uids) => { + for (const uid of uids) { + await batch.processSortedSet(`uid:${uid}:chat:room:${roomId}:mids`, async (mids) => { + const uniqMids = mids.filter(mid => !midsSeen.hasOwnProperty(mid)); + if (!uniqMids.length) { + return; } - }); - messageData = messageData.filter(Boolean); - const bulkSet = messageData.map( - msg => [`message:${msg.mid}`, { roomId: roomId }] - ); + let messageData = await db.getObjects(uniqMids.map(mid => `message:${mid}`)); + messageData.forEach((m, idx) => { + if (m) { + m.mid = parseInt(uniqMids[idx], 10); + } + }); + messageData = messageData.filter(Boolean); + + const bulkSet = messageData.map( + msg => [`message:${msg.mid}`, { roomId: roomId }] + ); - await db.setObjectBulk(bulkSet); - await db.sortedSetAdd( - `chat:room:${roomId}:mids`, - messageData.map(m => m.timestamp), - messageData.map(m => m.mid), - ); - uniqMids.forEach((mid) => { - midsSeen[mid] = 1; + await db.setObjectBulk(bulkSet); + await db.sortedSetAdd( + `chat:room:${roomId}:mids`, + messageData.map(m => m.timestamp), + messageData.map(m => m.mid), + ); + uniqMids.forEach((mid) => { + midsSeen[mid] = 1; + }); + }, { + batch: 500, }); - }, { - batch: 500, - }); - // eslint-disable-next-line no-await-in-loop - await db.deleteAll(`uid:${uid}:chat:room:${roomId}:mids`); - } - progress.incr(uids.length); - }, { - batch: 500, - }); - })); + // eslint-disable-next-line no-await-in-loop + await db.deleteAll(`uid:${uid}:chat:room:${roomId}:mids`); + } + progress.incr(uids.length); + }, { + batch: 500, + }); + } + } }, { batch: 500, }); From d1949cee0cf621095e2e09475650400cd9f9868a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 18 Aug 2023 12:10:01 -0400 Subject: [PATCH 03/13] lint: fix lint --- src/upgrades/3.3.0/chat_message_mids.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/upgrades/3.3.0/chat_message_mids.js b/src/upgrades/3.3.0/chat_message_mids.js index 36c331f1a8..5f97a85121 100644 --- a/src/upgrades/3.3.0/chat_message_mids.js +++ b/src/upgrades/3.3.0/chat_message_mids.js @@ -1,6 +1,6 @@ /* eslint-disable no-await-in-loop */ -'use strict'; +'use strict'; const db = require('../../database'); const batch = require('../../batch'); From db07ab150875613c798b8b193bbd1fb59d65398a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 18 Aug 2023 13:18:13 -0400 Subject: [PATCH 04/13] feat: #11930, ability to set custom skins as default --- public/src/admin/appearance/skins.js | 31 ++++++++++++------- .../appearance/skins/item-custom-skin.tpl | 3 +- src/views/admin/partials/theme_list.tpl | 2 +- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/public/src/admin/appearance/skins.js b/public/src/admin/appearance/skins.js index 9d3b7b92d3..04b2676615 100644 --- a/public/src/admin/appearance/skins.js +++ b/public/src/admin/appearance/skins.js @@ -2,8 +2,8 @@ define('admin/appearance/skins', [ - 'translator', 'alerts', 'settings', -], function (translator, alerts, settings) { + 'translator', 'alerts', 'settings', 'hooks', +], function (translator, alerts, settings, hooks) { const Skins = {}; Skins.init = function () { @@ -11,9 +11,19 @@ define('admin/appearance/skins', [ $.ajax({ method: 'get', url: 'https://bootswatch.com/api/5.json', - }).done(Skins.render); + }).done((bsData) => { + hooks.on('action:settings.sorted-list.loaded', (data) => { + if (data.hash === 'custom-skins') { + // lower case all custom-skin ids after load + $('.custom-skin-settings [data-type="list"] [data-theme]').each((i, el) => { + $(el).attr('data-theme', $(el).attr('data-theme').toLowerCase()); + }); + Skins.render(bsData); + } + }); + settings.load('custom-skins', $('.custom-skin-settings')); + }); - settings.load('custom-skins', $('.custom-skin-settings')); $('#save-custom-skins').on('click', function () { settings.save('custom-skins', $('.custom-skin-settings'), function () { alerts.success('[[admin/appearance/skins:save-custom-skins-success]]'); @@ -33,13 +43,12 @@ define('admin/appearance/skins', [ if (action && action === 'use') { const parentEl = target.parents('[data-theme]'); - const themeType = parentEl.attr('data-type'); const cssSrc = parentEl.attr('data-css'); const themeId = parentEl.attr('data-theme'); - + const themeName = parentEl.attr('data-theme-name'); socket.emit('admin.themes.set', { - type: themeType, + type: 'bootswatch', id: themeId, src: cssSrc, }, function (err) { @@ -52,7 +61,7 @@ define('admin/appearance/skins', [ alert_id: 'admin:theme', type: 'info', title: '[[admin/appearance/skins:skin-updated]]', - message: themeId ? ('[[admin/appearance/skins:applied-success, ' + themeId + ']]') : '[[admin/appearance/skins:revert-success]]', + message: themeId ? ('[[admin/appearance/skins:applied-success, ' + themeName + ']]') : '[[admin/appearance/skins:revert-success]]', timeout: 5000, }); }); @@ -67,7 +76,7 @@ define('admin/appearance/skins', [ themes: bootswatch.themes.map(function (theme) { return { type: 'bootswatch', - id: theme.name, + id: theme.name.toLowerCase(), name: theme.name, description: theme.description, screenshot_url: theme.thumbnail, @@ -82,9 +91,7 @@ define('admin/appearance/skins', [ if (app.config.bootswatchSkin) { const skin = app.config.bootswatchSkin; - highlightSelectedTheme( - skin.charAt(0).toUpperCase() + skin.slice(1) - ); + highlightSelectedTheme(skin); } }); }; diff --git a/src/views/admin/partials/appearance/skins/item-custom-skin.tpl b/src/views/admin/partials/appearance/skins/item-custom-skin.tpl index 005f7b6dab..951ce8aef6 100644 --- a/src/views/admin/partials/appearance/skins/item-custom-skin.tpl +++ b/src/views/admin/partials/appearance/skins/item-custom-skin.tpl @@ -1,9 +1,10 @@ -
  • +
  • {custom-skin-name}
    +
    diff --git a/src/views/admin/partials/theme_list.tpl b/src/views/admin/partials/theme_list.tpl index 4ac0a67743..b583511234 100644 --- a/src/views/admin/partials/theme_list.tpl +++ b/src/views/admin/partials/theme_list.tpl @@ -1,5 +1,5 @@ {{{ each themes }}} -
    +
    From 678a0e770e70c9ff15f7a9f6674193aa8916d9de Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Fri, 18 Aug 2023 17:36:28 +0000 Subject: [PATCH 05/13] chore: incrementing version number - v3.3.1 --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 99243a7955..8c3cc1085e 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "3.3.0", + "version": "3.3.1", "homepage": "https://www.nodebb.org", "repository": { "type": "git", From 6f961f9c4878f863cbd7545c2d90b70d3fa49d5f Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Fri, 18 Aug 2023 17:36:29 +0000 Subject: [PATCH 06/13] chore: update changelog for v3.3.1 --- CHANGELOG.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4cca4a71f..3ec39c8404 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,39 @@ +#### v3.3.1 (2023-08-18) + +##### Chores + +* up themes (62231baa) +* incrementing version number - v3.3.0 (fc1ad70f) +* update changelog for v3.3.0 (46f7405d) +* incrementing version number - v3.2.3 (b06d3e63) +* incrementing version number - v3.2.2 (758ecfcd) +* incrementing version number - v3.2.1 (20145074) +* incrementing version number - v3.2.0 (9ecac38e) +* incrementing version number - v3.1.7 (0b4e81ab) +* incrementing version number - v3.1.6 (b3a3b130) +* incrementing version number - v3.1.5 (ec19343a) +* incrementing version number - v3.1.4 (2452783c) +* incrementing version number - v3.1.3 (3b4e9d3f) +* incrementing version number - v3.1.2 (40fa3489) +* incrementing version number - v3.1.1 (40250733) +* incrementing version number - v3.1.0 (0cb386bd) +* incrementing version number - v3.0.1 (26f6ea49) +* incrementing version number - v3.0.0 (224e08cd) + +##### New Features + +* #11930, ability to set custom skins as default (db07ab15) + +##### Bug Fixes + +* some more upgrade script fixes (f23b0b5b) +* #11906, userData.sso — don't serve deauthUrl or non-associated url if caller uid is not same as target uid (19e047e2) +* include latin-ext subset of fonts in admin styles (#11918) (556a1c48) + +##### Other Changes + +* fix lint (d1949cee) + #### v3.3.0 (2023-08-16) ##### Chores From c02f1d70666839cfe83462448a0819909ad55b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 18 Aug 2023 16:17:19 -0400 Subject: [PATCH 07/13] fix: upgrade script --- src/upgrades/3.3.0/chat_room_refactor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/upgrades/3.3.0/chat_room_refactor.js b/src/upgrades/3.3.0/chat_room_refactor.js index 252484d18f..97fe6d6287 100644 --- a/src/upgrades/3.3.0/chat_room_refactor.js +++ b/src/upgrades/3.3.0/chat_room_refactor.js @@ -33,7 +33,7 @@ module.exports = { const arrayOfRoomData = await db.getObjects(roomIds.map(roomId => `chat:room:${roomId}`)); for (const roomData of arrayOfRoomData) { if (roomData) { - const midsSeen = Object.create(null); + const midsSeen = {}; const { roomId } = roomData; await batch.processSortedSet(`chat:room:${roomId}:uids`, async (uids) => { for (const uid of uids) { From 21116c4cdcb8b3c34af1f08559f35c49a8bcea4f Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Fri, 18 Aug 2023 20:29:02 +0000 Subject: [PATCH 08/13] chore: incrementing version number - v3.3.2 --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 8c3cc1085e..fe1241d406 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "3.3.1", + "version": "3.3.2", "homepage": "https://www.nodebb.org", "repository": { "type": "git", From 2ecf15c4d9efdff2106518563ad6297c28ec6847 Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Fri, 18 Aug 2023 20:29:03 +0000 Subject: [PATCH 09/13] chore: update changelog for v3.3.2 --- CHANGELOG.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ec39c8404..3c0ad6f4ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,29 @@ +#### v3.3.2 (2023-08-18) + +##### Chores + +* incrementing version number - v3.3.1 (151cc68f) +* update changelog for v3.3.1 (6f961f9c) +* incrementing version number - v3.3.0 (fc1ad70f) +* incrementing version number - v3.2.3 (b06d3e63) +* incrementing version number - v3.2.2 (758ecfcd) +* incrementing version number - v3.2.1 (20145074) +* incrementing version number - v3.2.0 (9ecac38e) +* incrementing version number - v3.1.7 (0b4e81ab) +* incrementing version number - v3.1.6 (b3a3b130) +* incrementing version number - v3.1.5 (ec19343a) +* incrementing version number - v3.1.4 (2452783c) +* incrementing version number - v3.1.3 (3b4e9d3f) +* incrementing version number - v3.1.2 (40fa3489) +* incrementing version number - v3.1.1 (40250733) +* incrementing version number - v3.1.0 (0cb386bd) +* incrementing version number - v3.0.1 (26f6ea49) +* incrementing version number - v3.0.0 (224e08cd) + +##### Bug Fixes + +* upgrade script (c02f1d70) + #### v3.3.1 (2023-08-18) ##### Chores From 90f29571f1004e50a1a70896b975aa5f071cd791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 18 Aug 2023 19:26:57 -0400 Subject: [PATCH 10/13] refactor: add connectionTimeout to psql only sleep if there is more than one iteration in processSortedSet --- src/database/mongo/connection.js | 2 +- src/database/mongo/sorted.js | 10 +++++----- src/database/postgres/connection.js | 2 ++ src/database/postgres/sorted.js | 9 +++++---- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/database/mongo/connection.js b/src/database/mongo/connection.js index 2f5d64e714..b5c375b4e6 100644 --- a/src/database/mongo/connection.js +++ b/src/database/mongo/connection.js @@ -44,7 +44,7 @@ connection.getConnectionString = function (mongo) { connection.getConnectionOptions = function (mongo) { mongo = mongo || nconf.get('mongo'); const connOptions = { - maxPoolSize: 10, + maxPoolSize: 20, minPoolSize: 3, connectTimeoutMS: 90000, }; diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js index 9dbf947b1a..4a8bbc691d 100644 --- a/src/database/mongo/sorted.js +++ b/src/database/mongo/sorted.js @@ -574,7 +574,7 @@ module.exports = function (module) { if (processFn && processFn.constructor && processFn.constructor.name !== 'AsyncFunction') { processFn = util.promisify(processFn); } - + let iteration = 1; while (!done) { /* eslint-disable no-await-in-loop */ const item = await cursor.next(); @@ -585,12 +585,12 @@ module.exports = function (module) { } if (ids.length >= options.batch || (done && ids.length !== 0)) { - await processFn(ids); - - ids.length = 0; - if (options.interval) { + if (iteration > 1 && options.interval) { await sleep(options.interval); } + await processFn(ids); + iteration += 1; + ids.length = 0; } } }; diff --git a/src/database/postgres/connection.js b/src/database/postgres/connection.js index 54cdc5ebee..19d796d7ed 100644 --- a/src/database/postgres/connection.js +++ b/src/database/postgres/connection.js @@ -28,6 +28,8 @@ connection.getConnectionOptions = function (postgres) { password: postgres.password, database: postgres.database, ssl: String(postgres.ssl) === 'true', + max: 20, + connectionTimeoutMillis: 90000, }; return _.merge(connOptions, postgres.options || {}); diff --git a/src/database/postgres/sorted.js b/src/database/postgres/sorted.js index 70e66af314..2b707a3a7d 100644 --- a/src/database/postgres/sorted.js +++ b/src/database/postgres/sorted.js @@ -677,7 +677,7 @@ SELECT z."value", z."score" if (process && process.constructor && process.constructor.name !== 'AsyncFunction') { process = util.promisify(process); } - + let iteration = 1; while (true) { /* eslint-disable no-await-in-loop */ let rows = await cursor.readAsync(batchSize); @@ -692,14 +692,15 @@ SELECT z."value", z."score" rows = rows.map(r => r.value); } try { + if (iteration > 1 && options.interval) { + await sleep(options.interval); + } await process(rows); + iteration += 1; } catch (err) { await client.release(); throw err; } - if (options.interval) { - await sleep(options.interval); - } } }; }; From 5a8e6af43e98a8cc345c66df67aa4cf09dfee857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 18 Aug 2023 20:13:35 -0400 Subject: [PATCH 11/13] fix: post preview on skins remove clearfix and floats --- src/views/partials/topic/post-preview.tpl | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/views/partials/topic/post-preview.tpl b/src/views/partials/topic/post-preview.tpl index 696a673f19..107075eef3 100644 --- a/src/views/partials/topic/post-preview.tpl +++ b/src/views/partials/topic/post-preview.tpl @@ -1,13 +1,11 @@ -
    -
    -
    +
    + -
    {post.content}
    From b5d1e9176bce172b773cdfbf6f76dfce7373d033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 18 Aug 2023 20:34:22 -0400 Subject: [PATCH 12/13] fix: one more upgrade script fix --- src/upgrades/3.3.0/chat_room_refactor.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/upgrades/3.3.0/chat_room_refactor.js b/src/upgrades/3.3.0/chat_room_refactor.js index 97fe6d6287..9b4f6a4096 100644 --- a/src/upgrades/3.3.0/chat_room_refactor.js +++ b/src/upgrades/3.3.0/chat_room_refactor.js @@ -20,10 +20,14 @@ module.exports = { // calculate user count and set progress.total await batch.processArray(allRoomIds, async (roomIds) => { - await Promise.all(roomIds.map(async (roomId) => { - const userCount = await db.sortedSetCard(`chat:room:${roomId}:uids`); - await db.setObjectField(`chat:room:${roomId}`, 'userCount', userCount); - progress.total += userCount; + const arrayOfRoomData = await db.getObjects(roomIds.map(roomId => `chat:room:${roomId}`)); + await Promise.all(roomIds.map(async (roomId, idx) => { + const roomData = arrayOfRoomData[idx]; + if (roomData) { + const userCount = await db.sortedSetCard(`chat:room:${roomId}:uids`); + await db.setObjectField(`chat:room:${roomId}`, 'userCount', userCount); + progress.total += userCount; + } })); }, { batch: 500, From 51587ca3b289b66d479fcf1158728c5ff45196f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 18 Aug 2023 20:38:59 -0400 Subject: [PATCH 13/13] fix: one more fix --- src/upgrades/3.3.0/chat_room_refactor.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/upgrades/3.3.0/chat_room_refactor.js b/src/upgrades/3.3.0/chat_room_refactor.js index 9b4f6a4096..fbf54418c3 100644 --- a/src/upgrades/3.3.0/chat_room_refactor.js +++ b/src/upgrades/3.3.0/chat_room_refactor.js @@ -25,7 +25,6 @@ module.exports = { const roomData = arrayOfRoomData[idx]; if (roomData) { const userCount = await db.sortedSetCard(`chat:room:${roomId}:uids`); - await db.setObjectField(`chat:room:${roomId}`, 'userCount', userCount); progress.total += userCount; } })); @@ -78,6 +77,8 @@ module.exports = { }, { batch: 500, }); + const userCount = await db.sortedSetCard(`chat:room:${roomId}:uids`); + await db.setObjectField(`chat:room:${roomId}`, 'userCount', userCount); } } }, {