I am not to sure how to go about doing this, and after any advice on my problem. As an example, i would like a similar feature to that of eBay where a item will have an expiry time and then will be set as closed or etc, once the time as finished. So similar i would like a Question to have a week of being open then after that week it will be set to different status of Resolved or something. How would i go about checking for this? and making update queries if the timer reaches zero? regards, Andrew Cetinick --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 4, 2007, at 6:54 PM, Chubbs wrote:> I am not to sure how to go about doing this, and after any advice on > my problem. > > As an example, i would like a similar feature to that of eBay where a > item will have an expiry time and then will be set as closed or etc, > once the time as finished. > > So similar i would like a Question to have a week of being open then > after that week it will be set to different status of Resolved or > something. How would i go about checking for this? and making update > queries if the timer reaches zero?The few times I''ve needed to do that, I started out thinking I needed something to actively "close" the record when the time was up. Not so (that can get quite complicated). All I actually needed was that any time a process tried to perform a task on that record, that task had to first see if the expiration time has passed. If so, the task interprets the record as closed, and acts accordingly. If you have a lot of tasks that might happen, then you don''t necessarily want to perform that calculation each time, so each task has the ability to mark a record as closed. So, now the task process is to first check if the record is closed, if not, check if it has expired. If yes, then mark it as closed. Now subsequent tasks will only have to do the first check. I called it a "lazy close." Of course the code is abstracted out so tasks can use it w/o duplicating the code that does the work. It may not be an appropriate strategy for all cases, but it worked for mine. -- gw --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
thanks for your advice. ye i was thinking of using an expiry date in the table, but im confused on when i do the check and updates, cos as you said i wouldnt want to calculate this each time i get a list of my questions. "now the task process is to first check if the record is closed". where would i go about implementing this method, will i do it in my model for Question (Tasks in ur example )? how would i implement this? im quite new to rails so dont know the methods which could accomplish this. On Nov 5, 2:18 pm, Greg Willits <li...-0Bv1hcaDFPRk211Z5VL+QA@public.gmane.org> wrote:> On Nov 4, 2007, at 6:54 PM, Chubbs wrote: > > > I am not to sure how to go about doing this, and after any advice on > > my problem. > > > As an example, i would like a similar feature to that of eBay where a > > item will have an expiry time and then will be set as closed or etc, > > once the time as finished. > > > So similar i would like a Question to have a week of being open then > > after that week it will be set to different status of Resolved or > > something. How would i go about checking for this? and making update > > queries if the timer reaches zero? > > The few times I''ve needed to do that, I started out thinking I needed > something to actively "close" the record when the time was up. Not so > (that can get quite complicated). All I actually needed was that any > time a process tried to perform a task on that record, that task had > to first see if the expiration time has passed. If so, the task > interprets the record as closed, and acts accordingly. > > If you have a lot of tasks that might happen, then you don''t > necessarily want to perform that calculation each time, so each task > has the ability to mark a record as closed. > > So, now the task process is to first check if the record is closed, > if not, check if it has expired. If yes, then mark it as closed. Now > subsequent tasks will only have to do the first check. I called it a > "lazy close." Of course the code is abstracted out so tasks can use > it w/o duplicating the code that does the work. > > It may not be an appropriate strategy for all cases, but it worked > for mine. > > -- gw--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
One thought is to create a custom finder method in your model, then use it in place of find. In that method, you could first do an update_all on the database using conditions that only update "expired" questions. This way you need not process any records manually and the result is limited to a single database call for an arbitrary number of records. Another option is to call the expiry update_all code from the controllers before_filter. One note about update_all is that it does not call any of the model callbacks nor does it check validation. Hope this helps and I am sure there will be other ideas. -Bill On Nov 4, 2007, at 7:32 PM, Chubbs wrote:> > thanks for your advice. > > ye i was thinking of using an expiry date in the table, but im > confused on when i do the check and updates, cos as you said i wouldnt > want to calculate this each time i get a list of my questions. > > "now the task process is to first check if the record is closed". > where would i go about implementing this method, will i do it in my > model for Question (Tasks in ur example )? > how would i implement this? im quite new to rails so dont know the > methods which could accomplish this. > > > > On Nov 5, 2:18 pm, Greg Willits <li...-0Bv1hcaDFPRk211Z5VL+QA@public.gmane.org> wrote: >> On Nov 4, 2007, at 6:54 PM, Chubbs wrote: >> >>> I am not to sure how to go about doing this, and after any advice on >>> my problem. >> >>> As an example, i would like a similar feature to that of eBay >>> where a >>> item will have an expiry time and then will be set as closed or etc, >>> once the time as finished. >> >>> So similar i would like a Question to have a week of being open then >>> after that week it will be set to different status of Resolved or >>> something. How would i go about checking for this? and making >>> update >>> queries if the timer reaches zero? >> >> The few times I''ve needed to do that, I started out thinking I needed >> something to actively "close" the record when the time was up. Not so >> (that can get quite complicated). All I actually needed was that any >> time a process tried to perform a task on that record, that task had >> to first see if the expiration time has passed. If so, the task >> interprets the record as closed, and acts accordingly. >> >> If you have a lot of tasks that might happen, then you don''t >> necessarily want to perform that calculation each time, so each task >> has the ability to mark a record as closed. >> >> So, now the task process is to first check if the record is closed, >> if not, check if it has expired. If yes, then mark it as closed. Now >> subsequent tasks will only have to do the first check. I called it a >> "lazy close." Of course the code is abstracted out so tasks can use >> it w/o duplicating the code that does the work. >> >> It may not be an appropriate strategy for all cases, but it worked >> for mine. >> >> -- gw > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 4, 2007, at 7:32 PM, Chubbs wrote:> thanks for your advice. > > ye i was thinking of using an expiry date in the table, but im > confused on when i do the check and updates, cos as you said i wouldnt > want to calculate this each time i get a list of my questions. > > "now the task process is to first check if the record is closed". > where would i go about implementing this method, will i do it in my > model for Question (Tasks in ur example )? > how would i implement this? im quite new to rails so dont know the > methods which could accomplish this.Much of the "how" depends on exactly what you''re doing, and how sensitive the exactness of the timing is. Are you writing a poll system? -- gw --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ye, a question answer system. question asked, goes into open status, after one week then goes into expired, then set as resolved or unresolved. thanks william. ill try look into using the before_filter to try implement it. On Nov 5, 3:07 pm, Greg Willits <li...-0Bv1hcaDFPRk211Z5VL+QA@public.gmane.org> wrote:> On Nov 4, 2007, at 7:32 PM, Chubbs wrote: > > > thanks for your advice. > > > ye i was thinking of using an expiry date in the table, but im > > confused on when i do the check and updates, cos as you said i wouldnt > > want to calculate this each time i get a list of my questions. > > > "now the task process is to first check if the record is closed". > > where would i go about implementing this method, will i do it in my > > model for Question (Tasks in ur example )? > > how would i implement this? im quite new to rails so dont know the > > methods which could accomplish this. > > Much of the "how" depends on exactly what you''re doing, and how > sensitive the exactness of the timing is. > > Are you writing a poll system? > > -- gw--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 4, 6:54 pm, Chubbs <acetin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am not to sure how to go about doing this, and after any advice on > my problem. > > As an example, i would like a similar feature to that of eBay where a > item will have an expiry time and then will be set as closed or etc, > once the time as finished. > > So similar i would like a Question to have a week of being open then > after that week it will be set to different status of Resolved or > something. How would i go about checking for this? and making update > queries if the timer reaches zero? > > regards, > > Andrew Cetinickyou could look at acts_as_draftable, REquires approval, and acts_as_publishable plugins http://svn.artofmission.com/svn/plugins/requires_approval http://fr.ivolo.us/posts/acts-as-publishable --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> On Nov 5, 3:07 pm, Greg Willits <li...-0Bv1hcaDFPRk211Z5VL+QA@public.gmane.org> wrote: >> On Nov 4, 2007, at 7:32 PM, Chubbs wrote: >> >>> thanks for your advice. >> >>> ye i was thinking of using an expiry date in the table, but im >>> confused on when i do the check and updates, cos as you said i >>> wouldnt >>> want to calculate this each time i get a list of my questions. >> >>> "now the task process is to first check if the record is closed". >>> where would i go about implementing this method, will i do it in my >>> model for Question (Tasks in ur example )? >>> how would i implement this? im quite new to rails so dont know the >>> methods which could accomplish this. >> >> Much of the "how" depends on exactly what you''re doing, and how >> sensitive the exactness of the timing is. >> >> Are you writing a poll system?On Nov 4, 2007, at 8:18 PM, Chubbs wrote:> ye, a question answer system. question asked, goes into open status, > after one week then goes into expired, then set as resolved or > unresolved.Seems to me you just need a date column that represents the date and time that the question is considered closed. When you do queries you include a conditional element which identifies whether you want records where closedDate is > today or < today. "show me open questions" would have a "WHERE closedDate >= today" -- gw --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---