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

706948 no replies #506

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/questions/models.py
Expand Up @@ -33,7 +33,6 @@
from sumo.parser import wiki_to_html
from sumo.redis_utils import RedisError
from sumo.urlresolvers import reverse
from taggit.models import TaggedItem
from tags.models import BigVocabTaggableMixin
from tags.utils import add_existing_tag
from upload.models import ImageAttachment
Expand Down Expand Up @@ -425,7 +424,10 @@ def save(self, no_update=False, no_notify=False, *args, **kwargs):
super(Answer, self).save(*args, **kwargs)

if new:
self.question.num_answers = self.question.answers.count()
# Need to pull from uncached, otherwise we get the cached
# query which doesn't reflect the answer we just saved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, since COUNT queries aren't cached, afaik.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I think this was a screwup on my part. I had cache machine caching counts locally and didn't discover it until after this went out. I'm now using cache settings more like what's on stage.

Given that I had "bad settings", this should get backed out since the comment is wrong and the code change shouldn't have any effect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that I had "bad settings", this should get backed out since the comment is wrong and the code change shouldn't have any effect.

I agree. If we were to opt into caching counts, I think we'd want them to be consistent.

self.question.num_answers = Answer.uncached.filter(
question=self.question).count()
self.question.last_answer = self
self.question.save(no_update)
self.question.clear_cached_contributors()
Expand Down