<commit_before># coding: utf-8
class ProjectsController < ApplicationController
  include SimpleCaptcha::ControllerHelpers

  load_and_authorize_resource only: [ :new, :create, :edit, :update, :send_to_analysis ]
  inherit_resources
  actions :new, :create, :edit, :update
  defaults finder: :find_by_permalink!
  has_scope :pg_search, :by_category_id
  has_scope :recent, :expiring, :successful, :recommended, :not_expired, :not_soon, :soon, type: :boolean

  respond_to :html
  respond_to :json, only: [:index, :show, :update]

  def index
    @city = user_city
    @project_locations = Project.with_state('online').locations
    @project_locations = @project_locations.concat([@city]) unless @project_locations.include?(@city)

    used_ids = [0]
    @featured = Project.with_state('online').featured.limit(1).first
    used_ids << @featured.id if @featured

    @recommended = Project.with_state('online').recommended.home_page.limit(1).where('id NOT IN (?)', used_ids).first
    used_ids << @recommended.id if @recommended

    @near_projects = Project.with_state('online').near(@city, 50).order('distance').where('id NOT IN (?)', used_ids).limit(4)
    used_ids += @near_projects.map(&:id) if @near_projects.any?

    @ending_soon = Project.expiring.home_page.where('id NOT IN (?)', used_ids).limit(4)
    @coming_soon = Project.soon.home_page.limit(8)
    @press_assets = PressAsset.order('created_at DESC').limit(5)
  end

  def near
    raise ActionController::UnknownController unless request.xhr?
    projects = apply_scopes(Project).with_state('online').near(params[:location], 30).visible.order('distance').page(params[:page]).per(4)
    render partial: 'project', collection: projects, layout: false
  end

  def create
    @project = current_user.projects.new(params[:project])
    create! do |success, failure|
      success.html do
        session[:successful_created] = resource.id
        return redirect_to success_project_path(@project)
      end<commit_msg>Remove used ids from near project on home page<commit_after># coding: utf-8
class ProjectsController < ApplicationController
  include SimpleCaptcha::ControllerHelpers

  load_and_authorize_resource only: [ :new, :create, :edit, :update, :send_to_analysis ]
  inherit_resources
  actions :new, :create, :edit, :update
  defaults finder: :find_by_permalink!
  has_scope :pg_search, :by_category_id
  has_scope :recent, :expiring, :successful, :recommended, :not_expired, :not_soon, :soon, type: :boolean

  respond_to :html
  respond_to :json, only: [:index, :show, :update]

  def index
    @city = user_city
    @project_locations = Project.with_state('online').locations
    @project_locations = @project_locations.concat([@city]) unless @project_locations.include?(@city)

    used_ids = [0]
    @featured = Project.with_state('online').featured.limit(1).first
    used_ids << @featured.id if @featured

    @recommended = Project.with_state('online').recommended.home_page.limit(1).where('id NOT IN (?)', used_ids).first
    used_ids << @recommended.id if @recommended

    @near_projects = Project.with_state('online').near(@city, 50).visible.order('distance').limit(4)
    used_ids += @near_projects.map(&:id) if @near_projects.any?

    @ending_soon = Project.expiring.home_page.where('id NOT IN (?)', used_ids).limit(4)
    @coming_soon = Project.soon.home_page.limit(8)
    @press_assets = PressAsset.order('created_at DESC').limit(5)
  end

  def near
    raise ActionController::UnknownController unless request.xhr?
    projects = apply_scopes(Project).with_state('online').near(params[:location], 30).visible.order('distance').page(params[:page]).per(4)
    render partial: 'project', collection: projects, layout: false
  end

  def create
    @project = current_user.projects.new(params[:project])
    create! do |success, failure|
      success.html do
        session[:successful_created] = resource.id
        return redirect_to success_project_path(@project)
      end
{'fraction_non_alphanumeric': 0.13363590519415028, 'fraction_numerical': 0.006555723651033787, 'mean_word_length': 5.001512859304085, 'pattern_counts': {'":': 0, '<': 13, '<?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': '7043496', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1232, 'n_words': 256}