Skip to content

Commit

Permalink
fix: Check length of possibly empty array (influxdata#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
scbrickley authored Mar 26, 2021
1 parent cb86c53 commit 0673d0d
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ spec:
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "runs")
|> filter(fn: (r) => r["_field"] == "logs")
|> map(fn: (r) => {
ind = regexp.findStringIndex(r: /name: \\\\\\".+?\\\\\\"/, v: r._value)
finalstring = strings.trimSuffix(v: strings.trimPrefix(v: strings.substring(end: ind[1], start: ind[0], v: r._value ), prefix: "name: \\\\\\\""), suffix: "\\\\\\\"")
return {r with name: finalstring }
}
|> map(
fn: (r) => {
ind = regexp.findStringIndex(r: /name: \\\\\\".+?\\\\\\"/, v: r._value)
finalstring = if length(arr: ind) > 1 then strings.trimSuffix(v: strings.trimPrefix(v: strings.substring(end: ind[1], start: ind[0], v: r._value ), prefix: "name: \\\\\\\""), suffix: "\\\\\\\"") else "none"
return {r with name: finalstring }
}
)
|> group(columns: ["_start"])
|> count()
Expand Down

0 comments on commit 0673d0d

Please sign in to comment.