Hey guys, I''ve got a table that stores events with a recurrence pattern. I found a stored procedure that will generate occurrence dates for an event between a start and end date. What I''m wondering is how to go about exploding a result set. For instance, if I have one row for an event, but there are 5 dates it falls on that are calculated on demand (not stored), how can I query with AREL to return 5 events, with the same data for each field plus a new field "date" that will contain the date of the occurrence? For instance, if the original table contained fields a, b, and c - the result of this method/query would be 5 objects with fields a, b, and c - but also one that stores the date. Thanks in advance, Jayme -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/KEIOBYmJqS8J. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mon, Jan 30, 2012 at 8:46 PM, Jayme Edwards <jayme.edwards-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Hey guys, > > I''ve got a table that stores events with a recurrence pattern. I found a > stored procedure that will generate occurrence dates for an event between a > start and end date. > > What I''m wondering is how to go about exploding a result set. For > instance, if I have one row for an event, but there are 5 dates it falls on > that are calculated on demand (not stored), how can I query with AREL to > return 5 events, with the same data for each field plus a new field "date" > that will contain the date of the occurrence? > > For instance, if the original table contained fields a, b, and c - the > result of this method/query would be 5 objects with fields a, b, and c - > but also one that stores the date. >Would you be able to show the raw SQL and the raw output of it (e.g. in psql or mysql) if you have that easily available? Thanks, Peter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It''s based loosely on this post: http://justatheory.com/computers/databases/postgresql/recurring_events.html. Basically I have events in the database with recurrence patterns. I want to return multiple instances of the same row per event over a range. I''ll need to show these occurrences for a variety of purposes (daily calendar view, summarized totals of things done during the occurrences) so if I can find a way to expose the occurrences as a hash or active record objects that I can then join via AREL that would be optimal. Thanks, Jayme -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/FTC0ZclLsOIJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 30 Jan 2012, at 21:54, Jayme Edwards wrote:> It''s based loosely on this post: http://justatheory.com/computers/databases/postgresql/recurring_events.html > . > > Basically I have events in the database with recurrence patterns. I > want to return multiple instances of the same row per event over a > range. I''ll need to show these occurrences for a variety of purposes > (daily calendar view, summarized totals of things done during the > occurrences) so if I can find a way to expose the occurrences as a > hash or active record objects that I can then join via AREL that > would be optimal.I haven''t been following the discussion too closely, but couldn''t you either switch to IceCube (https://github.com/seejohnrun/ice_cube) or maybe let some of the code inspire you? Best regards Peter De Berdt -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.