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
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
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.
Hope this helps and I am sure there will be other ideas.
-Bill
> 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
thanks william. ill try look into using the before_filter to try
implement it.
you 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
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