]> git.openstreetmap.org Git - rails.git/commitdiff
tidy up / remove debug
authorAdam Hoyle <atomoil@gmail.com>
Thu, 12 Aug 2021 08:43:27 +0000 (09:43 +0100)
committerAdam Hoyle <atomoil@gmail.com>
Thu, 12 Aug 2021 08:43:27 +0000 (09:43 +0100)
app/models/communities.rb

index 2379c59ad020df6cee7e5a54730b761b78395bac..f318157ce4e1fc3eaef36908aaeae1c0437be834 100644 (file)
@@ -1,36 +1,29 @@
 
-# require 'sprockets/railtie'
-
 class Communities
 
-  # include Sprockets::Helpers::RailsHelper
-
   def self.local_chapters
-    self.load_local_chapters
+    @local_chapters ||= self.load_local_chapters
   end
 
   protected
 
   def self.load_local_chapters
-    puts Dir.pwd
-    json_file = File.expand_path("node_modules/osm-community-index/dist/completeFeatureCollection.json", Dir.pwd);
-    # json_file = File.expand_path("./node_modules/osm-community-index", Dir.pwd);
 
-    path = File.exist?(json_file) # Dir.pwd # File.open(json_file, "r")
+    json_file = File.expand_path("node_modules/osm-community-index/dist/completeFeatureCollection.json", Dir.pwd);
     community_index = JSON.parse(File.read(json_file))
 
-    array_of_entries = []
+    local_chapters = []
     community_index['features'].each do |feature|
       feature['properties']['resources'].each do |id, data|
         data.each do |key, value|
           if key == "type" and value == "osm-lc" and data['strings']['community']
-            array_of_entries.push({ id: id, name: data['strings']['community'], url: data['strings']['url'] });
+            local_chapters.push({ id: id, name: data['strings']['community'], url: data['strings']['url'] });
           end
         end
       end
     end
 
-    return array_of_entries
+    return local_chapters
   end
 
 end