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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to