Advanced rule condition

Implement the first part of advanced rules, which is to add an aggregate and time window option