Skip to content

Instantly share code, notes, and snippets.

@tj tj/input.go
Last active Jul 19, 2019

Embed
What would you like to do?
// grab time spent
sum := Agg("duration_sum", Sum("duration"))
// grab time spent per label
labels := Agg("labels",
Terms("issue.labels.keyword", 100),
Aggs(sum))
// grab time spent per day, and per label
days := Agg("days",
DateHistogram("timestamp",
Interval("1d"),
TimeZone()),
Aggs(sum, labels))
// filter on a user and date range
filter := Filter(
Term("user.login", "tj"),
Range("now-7d", "now"))
// apply the filter
filtered := filter(Aggs(sum, labels, days))
// grab a week of data
week := Aggs(Agg("week", filtered))
// do stuff
query := Query(week)
{
"aggs": {
"week": {
"aggs": {
"days": {
"aggs": {
"duration_sum": {
"sum": {
"field": "duration"
}
},
"labels": {
"aggs": {
"duration_sum": {
"sum": {
"field": "duration"
}
}
},
"terms": {
"field": "issue.labels.keyword",
"size": 100
}
}
},
"date_histogram": {
"field": "timestamp",
"interval": "1d",
"time_zone": "-07:00"
}
},
"duration_sum": {
"sum": {
"field": "duration"
}
},
"labels": {
"aggs": {
"duration_sum": {
"sum": {
"field": "duration"
}
}
},
"terms": {
"field": "issue.labels.keyword",
"size": 100
}
}
},
"filter": {
"bool": {
"filter": [
{
"term": {
"user.login": "tj"
}
},
{
"range": {
"timestamp": {
"gte": "now-7d",
"lte": "now"
}
}
}
]
}
}
}
},
"size": 0
}
@joeytwiddle

This comment has been minimized.

Copy link

joeytwiddle commented Jun 2, 2017

You can use this userscript to display the tabs as something else: https://github.com/joeytwiddle/code/blob/master/other/gm_scripts/Tab_size/Tab_size.user.js

Sadly the current version does not work after navigation, it needs a reload to rerun on dynamically loaded files.

I will try to remember that ?ts=2 trick this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.