Skip to content

Instantly share code, notes, and snippets.

@tj
Last active July 19, 2019 11:45
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tj/63d7546994d63db47bb6247bf0eef7d0 to your computer and use it in GitHub Desktop.
Save tj/63d7546994d63db47bb6247bf0eef7d0 to your computer and use it in GitHub Desktop.
// 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
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