idle events
Posted: 07 October 2010 08:34 AM   [ Ignore ]
Newbie
Rank
Total Posts:  3
Joined  2010-06-30

I’ve been tasked with writing notification for idle events and i have a few questions that may help me choose a direction

Does IdleEvent.reading_id refer to the 1st reading when the event started, or does it get updated to contain the last reading for the event? Assuming that an idle event would span multiple readings.

If the reading_id does refer to the 1st event, how do i determine that a reading from the notification bounds belongs to an existing idle event?

Profile
 
 
Posted: 14 October 2010 02:54 PM   [ Ignore ]   [ # 1 ]
Newbie
Rank
Total Posts:  13
Joined  2009-01-07

Jeff,

The IdleEvent.reading_id does indeed refer to the first Reading that started the event.

While an IdleEvent is “in progress” it will have a null duration, but once the IdleEvent has ended, the duration will be inserted.

In order to know which Readings were part of the IdleEvent, you should be able to do something like the following given an IdleEvent called “event”:

Reading.all(:conditions => ['device_id = ? and created_at between ? and ?',event.device_id,event.created_at,event_created_at.advance(:minutes => event.duration)],:order => 'created_at'

Profile
 
 
   
 
 
‹‹ Data Pass Through      Mapping Updates ››