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

Set preferredPlace based on locality from locale. Implements #89 #208

Merged
merged 5 commits into from
Nov 24, 2020

Conversation

viatrix
Copy link
Contributor

@viatrix viatrix commented Aug 9, 2020

Intl.locale is available in Node.js since 13.0.0. I used polyfill for Intl, it will not be necessary after upgrade to a later version of Node.js. Tested on Node.js 12.13.0 and 13.11.0.
(Intl.locale could also be used in util.localeOpts).
Also, code and admin_level are not indexed in db now. Would it be better to add index for it?

@kueda
Copy link
Member

kueda commented Aug 10, 2020

@viatrix can you please commit your changes to package-log.json?

@viatrix
Copy link
Contributor Author

viatrix commented Aug 10, 2020

I'll merge recent updates of base repo with api-v2 and update the PR

@kueda
Copy link
Member

kueda commented Aug 10, 2020

If you're trying to get your branch up to date, you should pull from the main branch. The api-v2 is currently behind main so it shouldn't have anything that's not already in main.

@kueda
Copy link
Member

kueda commented Aug 12, 2020

Great, this is looking good to me. @pleary do you want to take a look to make sure this is working the way you were thinking when you wrote up #89?

@pleary
Copy link
Member

pleary commented Oct 14, 2020

Hi @viatrix - sorry I've let this sit for so long. This mostly looks great. I have a few things I'd want to change which might be easier to explain in code, so I'm wondering if you mind if I merge in this pull request then make a commit with some small changes?

One thing is req.userSession.locale isn't available in the lookupPreferredPlaceMiddleware middle because it hasn't been loaded yet. User session details get loaded later in preloadAndProcess. So one change I made is to extract some of the logic in lookupPreferredPlaceMiddleware into a shared method, which will get called in lookupPreferredPlaceMiddleware for the locale param, and we can implement it later for the user after the session is populated. But I actually don't think we need to, so we can stay consistent with the behavior of the website.

The only other change is to use squel when generating DB queries in the Place model. I've set a bad example by breaking this rule myself in the model, and have updated the model to use squel exclusively.

I don't think we'll hit issues with indices on the place model. admin_level does have an index on it, and unless we see performance problems I'd hold off on adding an additional dual-column index with code.

Thanks for your work on this!

@pleary pleary merged commit 12f5f0f into inaturalist:main Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants