Skip to content

Instantly share code, notes, and snippets.

@markuman
Created August 31, 2018 10:07
Show Gist options
  • Save markuman/ed9a80e3d3cc8bf6a3747a9628e59216 to your computer and use it in GitHub Desktop.
Save markuman/ed9a80e3d3cc8bf6a3747a9628e59216 to your computer and use it in GitHub Desktop.
with commits as(
select
created_unix as time_sec,
count(user_id) as value,
DATE_FORMAT( FROM_UNIXTIME(created_unix),
'%Y-%m-%d' ) as dates
from
`action`
where
user_id = 1
group by
DATE_FORMAT( FROM_UNIXTIME(created_unix),
'%Y%m%d' )
order by
created_unix ) select
ifnull( time_sec,
UNIX_TIMESTAMP(my_dates.dates)) as time_sec,
ifnull( value,
0 ) as value,
'commits' as metric
from
my_dates
left join commits on
( commits.dates = my_dates.dates )
where
$__timeFilter(my_dates.dates)
order by
my_dates.dates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment