[openstreetmap/openstreetmap-website] Communities page (#3256)
Adam Hoyle
notifications at github.com
Thu Jul 15 07:37:40 UTC 2021
> > Are there other examples of external data such as osm-community-index being loaded into the site (so that we can follow a similar pattern)?
>
> Not, not at the moment. But we have everything set up to use node modules (via packages.json and yarn) so we're good to go on that front. For loading the data I see two main approaches - either load it using an initializer, or create a model and load it via a memoization approach. See https://stackoverflow.com/questions/20913353/what-is-the-rails-way-to-quickly-access-static-data-at-runtime for some discussion. I lean slightly towards the model, since I suspect you'll want to write some code around that for returning records in a particular order.
Thanks @gravitystorm that's excellent and exactly what I was looking for. I'd definitely prefer the model approach as it encapsulates the functionality in a clear and open way.
I'm glad to hear node modules are supported - are there any good examples in the codebase that we can look at for best practise / to ensure consistency?
> Of course, if we start looking at ordering by user location (or map location) that might change the way we do things, perhaps by loading the data into the db in order to use postgres queries. We do something similar in the Language model, which essentially loads some static data into the db for further use. But in turn that opens up more discussions, like whether we should be using PostGIS for non-Node location-based queries, and that might be left for another time!
That's definitely an interesting idea, but I'd prefer to engineer for what we know we're planning as we can always refactor/adapt the approach if the requirements change to need user or map location.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/3256#issuecomment-880469091
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20210715/e29fdbcd/attachment-0001.htm>
More information about the rails-dev
mailing list