Skip to content

Instantly share code, notes, and snippets.

@ereshzealous
Created March 15, 2022 07:21
Show Gist options
  • Save ereshzealous/82ed83c5b8a88ebbc39d3b750350997d to your computer and use it in GitHub Desktop.
Save ereshzealous/82ed83c5b8a88ebbc39d3b750350997d to your computer and use it in GitHub Desktop.
data = from(bucket: "local")
|> range(start: -30d)
|> filter(fn: (r) => r["_measurement"] == "ticks")
|> filter(fn: (r) => r["_field"] == "price")
|> filter(fn: (r) => r["product"] == "AGUX/USD")
|> window(every: 1w) min = data
|> min()
|> set(key: "type", value: "min" ) max = data
|> max()
|> set(key: "type", value: "max" ) first = data
|> first()
|> set(key: "type", value: "first" ) last = data
|> last()
|> set(key: "type", value: "last" ) union(tables: [min, max, first, last])
|> group(columns:["type"], mode: "by")
|> yield()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment