Why not have a "user.membership_exp_date" field.  If a user signs up on day
0, the membership_exp_date could be set to now() + 5 days.

This will let you query the results in real-time. No cron job needed.

On Thu, Jul 15, 2010 at 12:27 PM, Continuation <selforgani...@gmail.com>wrote:

> I have groups that users can join.
>
> The difference  between this and "normal" groups is that membership is
> temporary - a user decides on joining to be a member for 5 days, a
> week, 2 weeks, etc (choices are pre-defined). Or potentially all
> memberships could be set to be of the same length - say a week - if
> that makes thing simpler.
>
> I'd like to have a running tally of the number of members of each
> group. The number doesn't need to be accurate up to the last second.
> But it can't be *too* out of date either - say, should be updated once
> a day.
>
> The "obvious" way to calculate the number of members seems to be
> running a cron job, say daily, and go through every member of every
> group  one by  one. If a membership has expired, remove that member
> from the group and decrement the group's membership count by 1.
>
> That approach seems very inefficient and not  very scalable. With a
> large number of groups, it  could take forever.
>
> Can you think of  a better way to do this?  The membership counts do
> not need to be  accurate to the latest second. It can be approximate
> and (slightly) out of date. Also if it makes a difference all
> memberships can be set to be of the same length, say a week.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Greg Pelly
CEO / CTO, Munchly Inc.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to