@k-yle commented on this pull request.
> +TAG2LINK = lambda {
+ # the JSON data is an array with duplicate entries, which is not efficient
for lookups.
+ # So, convert it to a hash and only keep the item with the best rank.
+ array = JSON.parse(Rails.root.join("node_modules/tag2link/index.json").read)
+
+ ranks = %w[deprecated normal preferred].freeze
+
+ output = {}
+
+ all_keys = array.map { |item| item["key"] }.uniq
+
+ all_keys.each do |key|
+ # for each key, find the item with the best rank
+ best_definition = array
+ .select { |item| item["key"] == key }
+ .max_by { |item| ranks.index(item["rank"]) }
since we're only talking about 17 examples here, I'd suggest we do not show the
link if there is >1 URL with the best rank.
As the `de:amtlicher_gemeindeschluessel` example shows, in these cases there
may not be a link that works for all values[^1]
[^1]: although.... shouldn't the federal https://statistikportal.de be
`preferred` if it includes all values?
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6197#discussion_r2212706114
You are receiving this because you are subscribed to this thread.
Message ID:
<openstreetmap/openstreetmap-website/pull/6197/review/3028532...@github.com>
_______________________________________________
rails-dev mailing list
rails-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/rails-dev