Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consistent normalization of line styles #1591

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ case class StyleExpr(expr: TimeSeriesExpr, settings: Map[String, String]) extend
// updates to the object.
val vs = settings.toList.sortWith(_._1 > _._1).map {
case ("sed", v) => v
case ("ls", v) => s":$v"
case (k, v) => s"$v,:$k"
}
if (vs.isEmpty) expr.toString else s"$expr,${vs.mkString(",")}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,11 @@ object ExprApi {
val rewritten = normalizeStat(expr).rewrite {
case q: Query => sort(q)
}
// Remove explicit :const, it can be determined from implicit conversion
// and adds visual clutter
rewritten.toString.replace(",:const", "")
// Remove explicit :const and :line, it can be determined from implicit conversion
// and add visual clutter
rewritten.toString
.replace(",:const", "")
.replace(",:line", "")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,27 @@ class ExprApiSuite extends MUnitRouteSuite {
val expected = "name,cpuUser,:eq,:sum,foo$(name)$(abc) bar$(def)baz,:legend"
assertEquals(normalize(expr), List(expected))
}

test("normalize :line") {
val expr = "app,foo,:eq,name,cpuUser,:eq,:and,:sum,(,stack,),:by"
assertEquals(normalize(expr), List(expr))
assertEquals(normalize(s"$expr,:line"), List(expr))
}

test("normalize :stack") {
val expr = "app,foo,:eq,name,cpuUser,:eq,:and,:sum,(,stack,),:by,:stack"
assertEquals(normalize(expr), List(expr))
}

test("normalize :area") {
val expr = "app,foo,:eq,name,cpuUser,:eq,:and,:sum,(,stack,),:by,:area"
assertEquals(normalize(expr), List(expr))
}

test("normalize :vspan") {
val expr = "app,foo,:eq,name,cpuUser,:eq,:and,:sum,(,stack,),:by,:vspan"
assertEquals(normalize(expr), List(expr))
}
}

object ExprApiSuite {
Expand Down