Last active
May 10, 2020 15:31
-
-
Save ayende/5826d7203c4ac92abe8c1d867b564e89 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
declare timeseries by30min(){ | |
from Temp | |
between '2020-01-01' and '2020-04-01' | |
group by 30m | |
select avg() | |
} | |
declare function fill_missing_range(d){ | |
for(var i = 0; i< d.Results.length-1;i++ ){ | |
if( new Date(d.Results[i].To).toISOString() >= | |
new Date(d.Results[i+1].From).toISOString()) | |
continue; | |
var cur = new Date(d.Results[i].From); | |
d.Results.splice(i+1, 0, { | |
From: new Date(cur.getTime() + 30*60000).toISOString(), | |
To: new Date(cur.getTime() + 60*60000).toISOString(), | |
Count: d.Results[i].Count, | |
Average: d.Results[i].Average | |
}); | |
} | |
return d; | |
} | |
from Containers where id() = 'containers/123918-A' | |
select fill_missing_range(by30min()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment