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

Fix part of #1366: Display relative (weekly) change in average ratings statistic #2252

Merged
merged 6 commits into from
Jul 24, 2016
Merged

Fix part of #1366: Display relative (weekly) change in average ratings statistic #2252

merged 6 commits into from
Jul 24, 2016

Conversation

526avijitgupta
Copy link
Contributor

@526avijitgupta 526avijitgupta commented Jul 13, 2016

Tasks to be completed as a part of this PR:

  • Create method to fetch last week's stats data.
  • Update serializers on both frontend and backend to send and recieve this data.
  • Create method to compute the relative change in average ratings on frontend.
  • Display this relative change in the view.
  • Fix precision of average ratings value. (truncate upto 2 decimal places)

@526avijitgupta
Copy link
Contributor Author

@wxyxinyu @AllanYangZhou Please review whenever free (not high priority, this PR doesn't block on any further work).

},
getRelativeChangeInAverageRating: function(newRating, oldRating) {
if (!oldRating) {
return '+' + parseFloat(newRating).toFixed(2);
Copy link
Contributor

@AllanYangZhou AllanYangZhou Jul 13, 2016

Choose a reason for hiding this comment

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

I'm not sure I understand the use of parseFloat here. From the tests you've written, it appears the arguments newRating and oldRating are numbers, not strings, right?

Copy link
Contributor Author

@526avijitgupta 526avijitgupta Jul 13, 2016

Choose a reason for hiding this comment

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

It's used to limit the result to just 2 places after the decimal. If I don't use this, then I get results which have many digits after decimal places!
Yes, both args are numbers.

Copy link
Contributor

@AllanYangZhou AllanYangZhou Jul 14, 2016

Choose a reason for hiding this comment

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

Ah, what I mean is that since numbers already have the toFixed method (see here) you should just be able to call newRating.toFixed(2)

parseFloat is for converting strings to numbers, if your arguments are already numbers you shouldn't need it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right. I've always been using toFixed with parseFloat without realizing that it can be directly used with numbers as well!
Removed use of parseFloat.

@codecov-io
Copy link

codecov-io commented Jul 13, 2016

Current coverage is 48.01% (diff: 0.00%)

Merging #2252 into develop will increase coverage by 0.01%

@@            develop      #2252   diff @@
==========================================
  Files           185        190     +5   
  Lines         15852      15917    +65   
  Methods        2720       2733    +13   
  Messages          0          0          
  Branches       2689       2694     +5   
==========================================
+ Hits           7609       7642    +33   
- Misses         8243       8275    +32   
  Partials          0          0          

Powered by Codecov. Last update 2aeb715...f895318

@wxyxinyu
Copy link
Contributor

code here lgtm

@526avijitgupta
Copy link
Contributor Author

@AllanYangZhou Do you have any other comments ?

@wxyxinyu
Copy link
Contributor

Are you going to do the last item on the checklist before merging though

@AllanYangZhou
Copy link
Contributor

@526avijitgupta No, what you've pushed looks good. Although, same question as @wxyxinyu.

@526avijitgupta
Copy link
Contributor Author

@wxyxinyu @AllanYangZhou Yes, I was actually waiting for #2238 to be merged before this. Since merge conflicts were inevitable! Sorry, I failed to mention this.
Now I'll complete the last item in checklist and mark this for review again.
Thanks!

@526avijitgupta
Copy link
Contributor Author

@AllanYangZhou @wxyxinyu PTAL. Made a bunch of changes.

@wxyxinyu
Copy link
Contributor

Could you test that the truncation works as intended?

@wxyxinyu
Copy link
Contributor

Other than that, LGTM, thanks!

@526avijitgupta
Copy link
Contributor Author

@wxyxinyu I had tested it manually a couple of times and it works fine. Did you mean that I move the truncation method to either utils or user_services, and then write tests for it in their corresponding test files ?

@@ -41,6 +41,9 @@ <h1 class="stat-value"><[dashboardStats.average_ratings || 'N/A']></h1>
<div class="total-plays stats-card">
<p class="stat-description">Total Plays</p>
<h1 class="stat-value"><[dashboardStats.total_plays]></h1>
<p ng-hide="(dashboardStats.total_plays - lastWeekStats.total_plays) == 0">
Copy link
Contributor

Choose a reason for hiding this comment

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

Recommend moving this calculation to the controller, since you're repeating it here twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@wxyxinyu
Copy link
Contributor

wxyxinyu commented Jul 24, 2016

@526avijitgupta -- Right, I think I was slightly confused about the tests earlier, I misread and thought you were storing the data truncated. I don't think you need to add anything. This can be merged once you address Allan's comment.

@526avijitgupta
Copy link
Contributor Author

@AllanYangZhou PTAL and merge if you think it's ok.

@AllanYangZhou AllanYangZhou merged commit fbce422 into oppia:develop Jul 24, 2016
@526avijitgupta 526avijitgupta deleted the creator-dashboard-weekly-stats-display branch July 24, 2016 18:06
wxyxinyu pushed a commit that referenced this pull request Aug 8, 2016
…s statistic (#2252)

* Fetch and compute relative change in average rating

* Removed use of parseFloat

* Fix average ratings precision, changes to relative change

* minor changes

* Move computation to controller instead of view
ctao5660 pushed a commit to ctao5660/oppia that referenced this pull request Nov 23, 2018
…atings statistic (oppia#2252)

* Fetch and compute relative change in average rating

* Removed use of parseFloat

* Fix average ratings precision, changes to relative change

* minor changes

* Move computation to controller instead of view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants