Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Participant count never increases #1676

Closed
SabreCat opened this issue Oct 30, 2013 · 3 comments
Closed

Participant count never increases #1676

SabreCat opened this issue Oct 30, 2013 · 3 comments

Comments

@SabreCat
Copy link
Member

Despite me participating in them, the Participants number on the challenges list shows 0:

screenclip

@paglias
Copy link
Contributor

paglias commented Oct 31, 2013

I get the count for a single challenge when I Join it...

@Shaners
Copy link
Contributor

Shaners commented Oct 31, 2013

Yea mine seemed to show 0 until I joined one.

@lefnire
Copy link
Contributor

lefnire commented Oct 31, 2013

fixed in ^ commit. Here's some brainstorming @paglias (nothing to worry about, just something for the mind-grapes). I added a memberCount attr to ChallengeSchema & GroupSchema a while back, to avoid having to calculate count every time on load for performance reasons, and I added a pre('save') Mongoose hook to update the count. Well it wasn't getting updated all the time. I realized it was because of this, which says: hooks only work when the object is loaded first (Challenge.find[ById|One|etc]()) and then .save()'d. save has to be called on the model object. It doesn't work for update operations Challenge.[update|findOneAndUpate|remove|etc](). I was about to just go through and switch all our updates to find-and-update, but especially with challenges - there are many places where it's much simpler to just fire off an async update in the background (like task syncing stuff).

Anyway, let me know if you think we should always use find-and-update and move a bunch of stuff to the mongoose middleware. I'm a bit back and forth on it

@lefnire lefnire closed this as completed Oct 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants