Skip to content

Commit be22915

Browse files
Misc improvements
1 parent 21e5044 commit be22915

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/utils.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,13 @@ const mergeStrings = (strings) => {
155155
}
156156
}
157157
}
158-
// Note that even though the ranges are inclusive-exclusive,
159-
// we are treating them as inclusive-inclusive here because we
160-
// want adjacent substrings to be picked up, as well.
158+
// We're now iterating through the picked-out characters and
159+
// the varying text ranges in parallel, incrementing either
160+
// one when the other has gotten too far ahead. Our goal is to
161+
// select for the particular picked-out characters that either
162+
// fall strictly within a varying range (for unchanged
163+
// characters) or fall within-or-adjacent-to a varying range
164+
// (for added characters).
161165
const varyingParts = [];
162166
let idx = 0, done = false;
163167
for (const range of varyingRanges) {
@@ -193,6 +197,11 @@ const mergeStrings = (strings) => {
193197
varyingLists.push(varyingParts);
194198
}
195199

200+
// Finally, we iterate through the varying and unchanged text
201+
// ranges in parallel, alternating between them (starting at
202+
// whichever one covers index zero) and inserting the
203+
// corresponding slices from the underlying strings, in order to
204+
// construct the final merged text.
196205
let varyingIdx = 0, unchangedIdx = 0;
197206
let onVarying = varyingRanges[0].start === 0;
198207

@@ -509,7 +518,7 @@ const utils = {
509518
if (omitAnnotation(annotation)) continue;
510519
if (!hasCommonAnnotation) {
511520
parts.push(`<br>`);
512-
hasCommonAnnotation;
521+
hasCommonAnnotation = true;
513522
}
514523
parts.push(` <br><b>${annotation}</b>: ${value}`);
515524
}
@@ -653,7 +662,7 @@ const utils = {
653662
const alerts = data.alerts.filter(
654663
alert => (
655664
alert.annotations.logs_template === logsTemplate &&
656-
alert.annotations.logs_datasource || defaultDatasource === logsDatasource
665+
(alert.annotations.logs_datasource || defaultDatasource) === logsDatasource
657666
),
658667
);
659668
const expr = logsTemplate.replace(/=~?"\$([a-z0-9_]+)"/g, (_, label) => {

0 commit comments

Comments
 (0)