<commit_before>class PositionsController < ApplicationController
  before_action :set_position, only: [:show, :edit, :update, :destroy, :vote]

  def vote
    @position.increment!(:votes)
    redirect_to root_path
  end

  def map
  end

  # GET /positions
  # GET /positions.json
  def index
    @positions = Position.all
    @geojson = Array.new

    @positions.each do |position|
      @geojson << {
        type: 'Feature',
        geometry: {
          type: 'Point',
          coordinates: [position.lon, position.lat]
        },
        properties: {
          id: position.id,
          name: position.name,
          description: position.description,
          votes: position.votes
        }
      }
    end
    respond_to do |format|
      format.html
      format.json { render json: @geojson }  # respond with the created JSON object
    end
  end

  # GET /positions/1
  # GET /positions/1.json
  def show
  end

  # GET /positions/new
  def new
    @position = Position.new
  end

  # GET /positions/1/edit
  def edit
  end

  # POST /positions
  # POST /positions.json
  def create
    @position = Position.new(position_params)

    respond_to do |format|
      if @position.save<commit_msg>Modified JSON format<commit_after>class PositionsController < ApplicationController
  before_action :set_position, only: [:show, :edit, :update, :destroy, :vote]

  def vote
    @position.increment!(:votes)
    redirect_to root_path
  end

  def map
  end

  # GET /positions
  # GET /positions.json
  def index
    @positions = Position.all
    @geojson = Array.new

    @points = Array.new
    @geojson << {
        type: 'FeatureCollection',
        features: @points
      }
    @positions.each do |position|
      @points << {
        type: 'Feature',
        geometry: {
          type: 'Point',
          coordinates: [position.lon, position.lat]
        },
        properties: {
          id: position.id,
          name: position.name,
          description: position.description,
          votes: position.votes
        }
      }


    end
    respond_to do |format|
      format.html
      format.json { render json: @geojson }  # respond with the created JSON object
    end
  end

  # GET /positions/1
  # GET /positions/1.json
  def show
  end

  # GET /positions/new
  def new
    @position = Position.new
  end

  # GET /positions/1/edit
  def edit
  end

  # POST /positions
  # POST /positions.json
  def create
    @position = Position.new(position_params)

    respond_to do |format|
      if @position.save
{'fraction_non_alphanumeric': 0.0970414201183432, 'fraction_numerical': 0.002366863905325444, 'mean_word_length': 2.134734239802225, 'pattern_counts': {'":': 0, '<': 11, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7377078', 'n_tokens_mistral': 804, 'n_tokens_neox': 763, 'n_words': 208}