<commit_before>class TodoController < ApplicationController

  def index
  	  @todos = Todo.all
  	  @all_todos_count = Todo.count
      @flag = 'all'
  end

  def active
  	@todos = Todo.where(complete: false)
    @all_todos_count = Todo.count
    @flag = 'active'
    render :index
  end

  def completed
	 @todos = Todo.where(complete: true)
	 @all_todos_count = Todo.count
	 @flag = 'completed'
   render :index
  end

  def create
  	hash = request.query
    hash["name"].strip!
    if hash["name"].length > 0 #if something was typed
    	Todo.create(hash) #then save the todo
	end
      redirect_to '/todo'
  end

  def toggle_all
  	Todo.toggle_all
    redeirect_to "/todo"
  end

  def clear_completed
  	Todo.clear_completed
    redeirect_to "/todo"
  end

  def edit 
  end


  def update
  end


  def toggle

  end


  def destroy
  end

<commit_msg>Add methods to controller<commit_after>class TodoController < ApplicationController

  def index
  	  @todos = Todo.all
  	  @all_todos_count = Todo.count
      @flag = 'all'
  end

  def active
  	@todos = Todo.where(complete: false)
    @all_todos_count = Todo.count
    @flag = 'active'
    render :index
  end

  def completed
	 @todos = Todo.where(complete: true)
	 @all_todos_count = Todo.count
	 @flag = 'completed'
   render :index
  end

  def create
  	hash = request.query
    hash["name"].strip!
    if hash["name"].length > 0 #if something was typed
    	Todo.create(hash) #then save the todo
	end
      redirect_to '/todo'
  end

  def toggle_all
  	Todo.toggle_all
    redeirect_to "/todo"
  end

  def clear_completed
  	Todo.clear_completed
    redeirect_to "/todo"
  end

  def edit 
    @todos = Todo.all
    todo = @todos.find(params[:id])
    todo.being_edited = true
    render :index
  end


  def update
    todo = @todos.find(params[:id])
    hash = request.query
    hash["name"].strip!
    if hash["name"].length > 0
      todo.update(hash)
    else
      todo.destroy
    end
    redeirect_to "/todo"
  end


  def toggle
    todo = Todo.find(params[:id])
    todo.toggle!(:complete)
    redirect_to '/todo'
  end


  def destroy
    todo = Todo.find(params[:id])
    todo.destroy
    redirect_to '/todo'
  end


{'fraction_non_alphanumeric': 0.09673024523160763, 'fraction_numerical': 0.0013623978201634877, 'mean_word_length': 2.5475040257648955, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '4433024', 'n_tokens_mistral': 838, 'n_tokens_neox': 800, 'n_words': 197}