<commit_before>require_dependency 'stash_datacite/application_controller'

module StashDatacite
  class GeolocationPointsController < ApplicationController
    before_action :set_geolocation_point, only: [:edit, :update, :delete]

    def index
      respond_to do |format|
        @geolocation_points = GeolocationPoint.from_resource_id(params[:resource_id])
        @resource = StashDatacite.resource_class.find(params[:resource_id])
        format.js
      end
    end

    # GET Leaflet AJAX index
    def points_coordinates
      respond_to do |format|
        @geolocation_points = GeolocationPoint.select(:resource_id, :id, :latitude, :longitude).
            from_resource_id(params[:resource_id])
        format.html
        format.json { render json:  @geolocation_points }
      end
    end

    # POST Leaflet AJAX create
    def map_coordinates
      geo = geolocation_by_point(params)
      unless geo
        geo = Geolocation.new_geolocation(point: [params[:latitude], params[:longitude]], resource_id: params[:resource_id])
      end
      @geolocation_point = geo.geolocation_point
      respond_to do |format|<commit_msg>filter geolocation points added as markers on map<commit_after>require_dependency 'stash_datacite/application_controller'

module StashDatacite
  class GeolocationPointsController < ApplicationController
    before_action :set_geolocation_point, only: [:edit, :update, :delete]

    def index
      respond_to do |format|
        @geolocation_points = GeolocationPoint.from_resource_id(params[:resource_id])
        @resource = StashDatacite.resource_class.find(params[:resource_id])
        format.js
      end
    end

    # GET Leaflet AJAX index
    def points_coordinates
      respond_to do |format|
        @geolocation_points = GeolocationPoint.select(:resource_id, :id, :latitude, :longitude).
            only_geo_points(params[:resource_id])
        format.html
        format.json { render json:  @geolocation_points }
      end
    end

    # POST Leaflet AJAX create
    def map_coordinates
      geo = geolocation_by_point(params)
      unless geo
        geo = Geolocation.new_geolocation(point: [params[:latitude], params[:longitude]], resource_id: params[:resource_id])
      end
      @geolocation_point = geo.geolocation_point
      respond_to do |format|
{'fraction_non_alphanumeric': 0.0794816414686825, 'fraction_numerical': 0.0, 'mean_word_length': 3.541176470588235, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4892011', 'n_tokens_mistral': 713, 'n_tokens_neox': 684, 'n_words': 144}