mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-30 17:32:26 +00:00
Merge pull request #2720 from PR0M3TH3AN/perf-watch-history-parallel-18111087127374532903
⚡ Optimize watch history publishing with Promise.all
This commit is contained in:
1 file changed
+3
-5
@@ -1234,17 +1234,15 @@ class WatchHistoryManager {
|
||||
|
||||
const months = Object.keys(records).sort();
|
||||
|
||||
const results = await pMap(
|
||||
months,
|
||||
async (month) => {
|
||||
const results = await Promise.all(
|
||||
months.map(async (month) => {
|
||||
const items = records[month];
|
||||
// Ideally we check if this month changed before publishing.
|
||||
// For now, we rely on the caller or just publish.
|
||||
// In a real optimized system we'd track dirty flags per month.
|
||||
|
||||
return this.publishMonthRecord(month, items, options);
|
||||
},
|
||||
{ concurrency: 5 },
|
||||
}),
|
||||
);
|
||||
|
||||
for (const res of results) {
|
||||
|
||||
Reference in new issue
Block a user