On Tue, Aug 16, 2011 at 7:09 AM, Genji <[email protected]> wrote:

> Hello there,
>
> I'm still "new" to ruby on rails, i try to create a little
> browsergame. For that, I have to control the "resources" of a village.
> For example:
> The village got a wood rate of 200 per hour, so i want to call every
> hour a method/action (anything) that count the 200 to the rest wood.
> But of course, i need to do this with every village.
>
> Since yet I did some easy code with delayed job and it all worked
> fine, but now i think about how to create this big background job. One
> option to start it would be at the first creation of a village but
> how? But i thought about it, setting it up with delayed job and
> running an method that check hundreds of villages, it sounds a little
> nonproductive and a waste of time.
> Btw. that would mean, that one worker is all the time busy and can't
> do anything else or not? I mean thats really annoying cause he is
> frozen for the most time - doing nothing. What of course mean i need a
> second worker and then heroku is not "for free" anymore?
> So what do you think is the best way(with or without delayed_job) to
> handle this job?
>
> Has anyone an example site which had the same problem?
>
> Ps: is there a way to start the code every full hour? I think using
> sleep could be a second problem with many villages. For that long
> running code it wouldn't be anymore "every full hour" it would turn in
> every hour and a half, or not?
>
>
Everytime the page loads, compute the total resources of the user based on
the last time
you updated the resources of that user.  Then add a js that would send an
ajax request
that would update the resources.  No background job needed.  So for example,
a user last
logged out at 7:00 PM.  The next day, that same user logged in at 7:30 AM.
 That would mean
that that user's resources should increase by 12 hours worth of resources
and your js should
fire after 30 mins.


> Greetings
> Genji
>
> --
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


-- 
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.com

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to