@tomhughes commented on this pull request.


> @@ -0,0 +1,25 @@
+# A map of each OSM key to its formatter URL. For example:
+# { "ref:vatin" => "https://example.com/$1"; }
+TAG2LINK = lambda {
+  # the JSON data is an array with duplicate entries, which is not efficient 
for lookups.

Why do we need an immediately invoked lambda here? Just to avoid namespace 
pollution? You could actually write it all with only one variable other than 
the end result:

```ruby
TAG2LINK = JSON.parse(Rails.root.join("node_modules/tag2link/index.json").read)
               .reject { |item| item["rank"] == "deprecated" }
               .group_by { |item| item["key"] }
               .transform_keys { |key| key.sub(/^Key:/, "") }
               .transform_values { |items| items.max_by { |item| 
ranks.index(item["rank"]) }.fetch("url") }
```

which just needs the array of ranks...

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6197#pullrequestreview-3025807777
You are receiving this because you are subscribed to this thread.

Message ID: 
<openstreetmap/openstreetmap-website/pull/6197/review/3025807...@github.com>
_______________________________________________
rails-dev mailing list
rails-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to