Ken Barker
2005-Sep-07 02:29 UTC
Design/Ruby Question: How best to activate items for display based on to from dates and day of week
I have an application that allows for items to be ''active'' or ''selectable'' by the user for a given date range. To complicate matters, there is often an item that is ''active'' or ''selectable'' only on weekends and holidays _or_ conversely items that should only be available for selection on business days. Any ideas on how best to implement this, both from a database perspective and a ruby perspective(any ruby magic??). I have in the past forced the admin user to enter every single discrete date range and item combination. This has proven to be very tedious on the admin user and wicked crazy when building the SQL to return the items in a category that are ''active'' on a particular day. I would hate to recreate the problems I had in this earlier app in my new web 2.0 version. Thoughts? Ken
François Beausoleil
2005-Sep-07 12:39 UTC
Re: Design/Ruby Question: How best to activate items for display based on to from dates and day of week
Hello Ken, Ken Barker said the following on 2005-09-06 22:29:> I have an application that allows for items to be ''active'' or > ''selectable'' by the user for a given date range. To complicate > matters, there is often an item that is ''active'' or ''selectable'' only > on weekends and holidays _or_ conversely items that should only be > available for selection on business days. >[snip]> Thoughts?Yup, in the DB, keep the discrete time ranges. In the UI layer, ask for anything - date range with weekends only, and convert from that to discrete date ranges. The SQL is super easy, and the hardest part is parsing what the user wants. In fact, your UI becomes some kind of domain language for specifying date ranges. Hope that helps ! François