[bug 747917] Add recent questions stats on top of /questions. #593

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
2 participants
Member

rlr commented May 7, 2012

I added some class methods to Question to pull the metrics I need and added tests for that. The rest is mostly UI stuff.

r?

+ <p class="no-reply">
+ {% trans num=(recent_asked_count - recent_answered_count),
+ url=url('questions.questions')|urlparams(filter='recent-unanswered') %}
+ <strong>{{num}}</strong> questions in the last <strong>3 days</strong> have no reply.
@willkg

willkg May 7, 2012

Member

Doesn't this fail in the 1 case (in English) and print "1 questions in the last 3 days"? In Polish, this fails in the 1 and 2 cases (I think that's right).

@rlr

rlr May 7, 2012

Member

You are right, we need to handle that. I'll search for a similar case in the codebase.

+ {% endtrans %}
+ </p>
+ <div class="graph">
+ <div style="width: {{ recent_answered_percent }}%;">
@willkg

willkg May 7, 2012

Member

Wow--that's so cool! I never thought of doing that.

@rlr

rlr May 7, 2012

Member

shhh, i hate putting CSS in the HTML but I don't see any other good option here :-)

apps/questions/tests/test_models.py
+ question(created=now - timedelta(hours=24), save=True)
+ q = question(created=now - timedelta(hours=48), save=True)
+ answer(question=q, save=True)
+ question(created=now - timedelta(hours=72), save=True)
@willkg

willkg May 7, 2012

Member

This is a little goofy, but I'd put 73 here instead of 72 since that's definitely outside the boundary. I can't tell if it's possible for the timings to be such that there's an edge case where it ends up being inside the boundary and shows up in the "from last 72 hours" list.

@rlr

rlr May 7, 2012

Member

True, I don't want to add any test cases that fail randomly.

Member

rlr commented May 8, 2012

not sure if you were done looking yet, but here is the update based on your feedback so far ^^

Wow! I had no idea you could do that. That's wild.

Member

willkg commented May 8, 2012

This looks good to me. Tests pass. r+

Member

rlr commented May 8, 2012

@rlr rlr closed this May 8, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment