Skip to content

Instantly share code, notes, and snippets.

@ayende
Last active May 10, 2020 15:31
Show Gist options
  • Save ayende/5826d7203c4ac92abe8c1d867b564e89 to your computer and use it in GitHub Desktop.
Save ayende/5826d7203c4ac92abe8c1d867b564e89 to your computer and use it in GitHub Desktop.
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