-
Notifications
You must be signed in to change notification settings - Fork 1
Alarms
Once user creates a car and attach a device to it and start receiving data, he may want to create alarms, to say hey alert me whenever this car's driver doesn't respect speed limit and/or using the car outside work hours.
Since user should have choice over how many rules an alarm can include and how they are combined (OR vs AND), that's why each Alarm
can include more than one Rule
.
Rules aren't create dynamically, they're actually create through a seed file, and there is 8 predefined rules so far, and they are independant of the user or the company, and each Rule
has it's own business logic and they are all defined in app/models/rule.rb
A Rule has a name and a method_name, and they represent the business logic that will check if a car is used outside work hours or not (by looking at the car schedule and the current time and position).
For example in app/models/rule.rb
there is a method called stopped_for_more_than
that given a car_id
it will check if that car stopped for more than a specific number of minutes.