<commit_before>module API
class Base < Grape::API
  prefix "api"
  format :json

  helpers do
  end

  resource :projects do
    desc "Return all projects"
    params do
      optional :page, type: Integer, default: 1
    end
    get "/" do
      @projects = Project.where(is_public: true).page(params[:page]).per(30)
    end

    desc "Return a project"
    get "/:id" do
      begin
        @project = Project.find(params[:id])
      rescue
        error!("NotFound", 404)
      end
      return {"status": 200, "message": "OK"}
    end

    desc "create Project"
    params do
      optional :title, type: String
      optional :description, type: String
    end
    post "/" do
      error!("BadRequest", 400) unless params[:title] && params[:description]
      @project = Project.new(title: params[:title], description: params[:description], is_public: false)
      #error!("OK", 200)
      return {"status": 200, "message": "OK"}
    end

    desc "delete Project"
    delete "/:id" do
      begin
        @project = Project.find(params[:id])
      rescue
        error!("NotFound", 404)
      end
      if @project.destroy
        return {"status": 200, "message": "OK"}
      end
    end
  end
<commit_msg>GETレスポンス変更<commit_after>module API
class Base < Grape::API
  prefix "api"
  format :json

  helpers do
  end

  resource :projects do
    desc "Return all projects"
    params do
      optional :page, type: Integer, default: 1
    end
    get "/" do
      @projects = Project.where(is_public: true).page(params[:page]).per(30)

    end

    desc "Return a project"
    get "/:id" do
      begin
        @project = Project.find(params[:id])
      rescue
        error!("NotFound", 404)
      end
      return {"status": 200, "message": "OK"} if @project
    end

    desc "create Project"
    params do
      optional :title, type: String
      optional :description, type: String
    end
    post "/" do
      error!("BadRequest", 400) unless params[:title] && params[:description]
      @project = Project.new(title: params[:title], description: params[:description], is_public: false)
      #error!("OK", 200)
      return {"status": 200, "message": "OK"}
    end

    desc "delete Project"
    delete "/:id" do
      begin
        @project = Project.find(params[:id])
      rescue
        error!("NotFound", 404)
      end
      @project.destroy
      return {"status": 200, "message": "OK"} if @project.frozen?
    end
  end

{'fraction_non_alphanumeric': 0.13098649201801063, 'fraction_numerical': 0.019647973802701595, 'mean_word_length': 2.4568599717114568, 'pattern_counts': {'":': 12, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3904976', 'n_tokens_mistral': 782, 'n_tokens_neox': 734, 'n_words': 228}