<commit_before>module LooseChange
  module Spatial

    def geo_point(name)
      design_doc = JSON.parse(RestClient.get("#{ database.uri }/_design/#{ CGI.escape(model_name) }"))
      RestClient.put("#{ database.uri }/_design/#{ CGI.escape(model_name) }",
                       design_doc.merge({"spatial" => {"points" => "function(doc) {\n    if (doc.#{name}) {\n        emit({\n            type: \"Point\",\n            coordinates: [doc.#{name}[0], doc.#{name}[1]]\n        }, [doc._id, doc.#{name}]);\n    }};"}}).to_json, default_headers)
      property(name)
    end
      
    def by_bounding_box(lat1, lng1, lat2, lng2)
      JSON.parse(RestClient.get("#{ database.uri }/_design/#{ CGI.escape(model_name) }/_spatial/points?bbox=#{ [lat1,lng1,lat2,lng2].join(',') }", default_headers))['rows'].map do |row|
        find(row['id'])
      end
    end
    
  end
end<commit_msg>Fixed last commit.<commit_after>module LooseChange
  module Spatial

    def geo_point(name)
      design_doc = JSON.parse(RestClient.get(design_document_uri(database, model_name)))
      function =<<JS
        function(doc) {
          if (doc.#{name} && doc.model_name == "#{ model_name }") {
            emit({ type: "Point",
                   coordinates: doc.#{name} },
                 [doc._id, doc.#{name}]); }
        }
JS
      RestClient.put(design_document_uri(database, model_name),
                     design_doc.merge({"spatial" => {"points" => function}}).to_json, default_headers)
      property(name)
    end
    
    def geo_multipoint(name)
      design_doc = JSON.parse(RestClient.get(design_document_uri(database, model_name)))
      function =<<JS
        function(doc) {
          if (doc.#{name} && doc.model_name == "#{ model_name }") {
            emit({ type: "MultiPoint",
                   coordinates: doc.#{name} },
                 [doc._id, doc.#{name}]); }};
JS
      RestClient.put(design_document_uri(database, model_name),
                     design_doc.merge({"spatial" => {"points" => function}}).to_json, default_headers)
      property(name)
    end
    
    def by_bounding_box(lat1, lng1, lat2, lng2)
      JSON.parse(RestClient.get("#{ database.uri }/_design/#{ CGI.escape(model_name) }/_spatial/points?bbox=#{ [lat1,lng1,lat2,lng2].join(',') }", default_headers))['rows'].map do |row|
        find(row['id'])
      end
    end
    
  end
end
{'fraction_non_alphanumeric': 0.17305263157894737, 'fraction_numerical': 0.007578947368421052, 'mean_word_length': 2.594553706505295, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '212931', 'n_tokens_mistral': 805, 'n_tokens_neox': 800, 'n_words': 133}