Skip to content

Instantly share code, notes, and snippets.

@JefClaes
Created November 16, 2014 12:08
Show Gist options
  • Select an option

  • Save JefClaes/b482f8b6021f70153b7a to your computer and use it in GitHub Desktop.

Select an option

Save JefClaes/b482f8b6021f70153b7a to your computer and use it in GitHub Desktop.
streamIsHot function
let streamIsHot (events : seq<Event>) treshold secondsInWindow =
let folder acc e =
let detect acc e =
let windowFilter = (fun x -> x >= e.Timestamp.AddSeconds(- float secondsInWindow))
let window = e.Timestamp :: acc.Window |> List.filter windowFilter
let hot = (window |> Seq.length) > treshold
{ acc with Hot = hot; Window = window }
match acc.Hot with
| true -> acc
| false -> detect acc e
(Seq.fold folder initialDetectionResult events).Hot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment