<commit_before>class ProjectsController < ApplicationController
  before_filter :must_be_logged_in, :except => [:show, :new, :create]
  before_filter :verify_user_can_edit, :only => [:destroy]
  before_filter :redirect_to_chapter_or_sign_in, :only => [:index], :if => :chapter_missing?
  before_filter :must_be_logged_in_to_see_unpublished_projects, :only => [:show]

  include ApplicationHelper

  def index
    @chapter = Chapter.find(params[:chapter_id])
    @start_date, @end_date = extract_timeframe
    @short_listed = params[:short_list]
    project_filter = ProjectFilter.new(@chapter.projects).during(@start_date, @end_date)
    if params[:short_list]
      project_filter.shortlisted_by(current_user)
    end
    respond_to do |format|
      format.html do
        @projects = project_filter.page(params[:page]).result
        current_user.mark_last_viewed_chapter(params[:chapter_id])
      end
      format.csv do
        if export_all?
          @projects = Project.during_timeframe(@start_date, @end_date)
        else
          @projects = project_filter.result
        end
        render :text => Project.csv_export(@projects), :content_type => 'text/csv'
      end<commit_msg>Add Content-Disposition header to project export to ensure the CSV gets saved as a file. Closes #63<commit_after>class ProjectsController < ApplicationController
  before_filter :must_be_logged_in, :except => [:show, :new, :create]
  before_filter :verify_user_can_edit, :only => [:destroy]
  before_filter :redirect_to_chapter_or_sign_in, :only => [:index], :if => :chapter_missing?
  before_filter :must_be_logged_in_to_see_unpublished_projects, :only => [:show]

  include ApplicationHelper

  def index
    @chapter = Chapter.find(params[:chapter_id])
    @start_date, @end_date = extract_timeframe
    @short_listed = params[:short_list]
    project_filter = ProjectFilter.new(@chapter.projects).during(@start_date, @end_date)
    if params[:short_list]
      project_filter.shortlisted_by(current_user)
    end
    respond_to do |format|
      format.html do
        @projects = project_filter.page(params[:page]).result
        current_user.mark_last_viewed_chapter(params[:chapter_id])
      end
      format.csv do
        if export_all?
          @projects = Project.during_timeframe(@start_date, @end_date)
        else
          @projects = project_filter.result
        end

        headers["Content-Disposition"] = "attachment; filename=#{@chapter.slug}_export.csv"
        render :text => Project.csv_export(@projects), :content_type => 'text/csv'
      end
{'fraction_non_alphanumeric': 0.10565302144249512, 'fraction_numerical': 0.0007797270955165692, 'mean_word_length': 4.081188118811881, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '2256417', 'n_tokens_mistral': 806, 'n_tokens_neox': 778, 'n_words': 152}