-
Notifications
You must be signed in to change notification settings - Fork 25
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
User dashboard: add quick summary of num missions, labels, accuracy, etc. #2280
Comments
@misaugstad, can you help me with this query for calculating the number of validations performed by the given user:
|
This should be as simple as
And in Slick,
I'd just put it in LabelValidationTable.scala |
First off, As for internationalization, I'm actually going to give you way more info than you need, but it should help you to easily incorporate translations in the future. There are two places that translations are stored, one for JavaScript and one for Scala/Play. For JavaScript, translations are stored in public/locales/<language-code>. In particular, in public/locales/en-US/common.json we have these lines:
You can see how these are used in the old user dashboard code (it's not particularly pretty in this case):
And you are able to use the
and if you've initialized the i18n library. You can see this in userProfile.scala.html:
Note that in here, we know which language to load because Play tells us using
and you access using So in summary, if you are doing translations/conversions in Scala, use AND FINALLY the actual conversion. I think that I would recommend actually pulling the call to You can see a very similar example in our conversion of distances for the landing page. In ApplicationController.scala, the conversion happens here:
Then that value is passed in to the landing page HTML (index.scala.html) and used as-is:
But in the actual HTML, we check for the correct unit:
|
Yeah on the current user dashboard we have been calculating distance using the JavaScript turf library, looking at the list of completed street edges. We've moved just about everything over to looking at the some of completed mission distance instead of that, so I think it's good that you're switching to using |
Added validations as discussed #2280 (comment)
OK, in trying to complete the final piece of this this morning, I have too many questions to finish it. So, I'll need to wait until you're back online to make progress. First, regarding shifting the method Secondly,
But obviously I don't have access to the missions variable in
Thirdly, none of the user dashboard stats calls in my new implementation are asynchronous. Should they be? See below:
|
I was not suggesting that you move the method there. I was suggesting that instead of calling it in
That is a great question. I think that in the case where we care about performance (page load time) above all else, these should all be asynchronous calls. In practice, writing it this way is just so much simpler than asynchronous calls, because to do that, you need to add a new route to the However, since all of these queries should be quite fast, I think that the current method you're using is ideal. Much less code. No noticeable difference in performance. |
Gotcha. Thanks. Could you re-explain how to do the unit conversion for the distance stuff? I didn't fully grok it. We store things in the database in metric, right? So this call |
I think that explaining it in so many words can be a bit confusing. It is probably easier to look at an example and possibly the documentation. This is for doing it in Scala. |
I am splitting up #1363 into individual pieces for the user dashboard.
This Issue covers removing the line graph and historic activity table and replacing them with a quick summary of activity, including missions, labels, validations, and, crucially, accuracy.
Old design:
Implemented redesign:
A few things remain:
@MissionTable.getDistanceAudited(user.get.userId)
is returning different results from@Messages("dashboard.distance")
(or the old table where it says "Total Distance Explored"):The text was updated successfully, but these errors were encountered: