Last active
July 19, 2019 11:45
-
-
Save tj/63d7546994d63db47bb6247bf0eef7d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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 | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.