Skip to content

Commit 9a39a38

Browse files
author
Niels V
committed
only do grouping once on service start
1 parent 97b69c8 commit 9a39a38

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

app.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ import {
1717
if( process.env["LOG_SERVER_CONFIGURATION"] )
1818
console.log(JSON.stringify( services ));
1919

20+
const groupedServices = services.reduce((acc, service) => {
21+
// Create a unique key for the match pattern
22+
const matchKey = `${normalizeObject(service.match)}${service.options.sendMatchesOnly || false}`;
23+
if (!acc[matchKey]) {
24+
acc[matchKey] = [];
25+
}
26+
acc[matchKey].push(service);
27+
return acc;
28+
}, {});
29+
30+
2031
app.get( '/', function( req, res ) {
2132
res.status(200);
2233
res.send("Hello, delta notification is running");
@@ -75,17 +86,8 @@ function filterChangesestOnPattern(changeSets, entry) {
7586
return filteredChangesets;
7687
}
7788

78-
async function informWatchers( changeSets, res, muCallIdTrail, muSessionId ){
79-
const groupedServices = services.reduce((acc, service) => {
80-
// Create a unique key for the match pattern
81-
const matchKey = `${normalizeObject(service.match)}${service.options.sendMatchesOnly || false}`;
82-
if (!acc[matchKey]) {
83-
acc[matchKey] = [];
84-
}
85-
acc[matchKey].push(service);
86-
return acc;
87-
}, {});
8889

90+
async function informWatchers( changeSets, res, muCallIdTrail, muSessionId ){
8991
// Iterate over each unique match pattern
9092
for (const matchKey in groupedServices) {
9193
const firstEntry = groupedServices[matchKey][0];

0 commit comments

Comments
 (0)