<commit_before>require 'spec_helper'

resource "Insights" do
  let(:user) { users(:owner) }
  let(:note) { Events::NoteOnGreenplumInstance.last }

  before do
    log_in user
  end

  post "/insights/promote" do
    parameter :note_id, "Id of the Note being promoted"

    let(:note_id) { note.id }

    example_request "promote the note to insight" do
      status.should == 201
    end
  end

  get "/insights" do
    parameter :entity_id, "Entity Id for filtering insights"
    parameter :entity_type, "Entity_type (dashboard or workspace)"

    required_parameters :entity_type

    let(:entity_type) {"workspace"}
    let(:entity_id) {1}

    example_request "get the list of insights" do
      status.should == 200
    end
  end

  get "/insights/count" do

    parameter :entity_id, "Entity Id for filtering insights"
    parameter :entity_type, "Entity_type (dashboard or workspace)"

    required_parameters :entity_type

    let(:entity_type) {"dashboard"}
    example_request "get the number of insights" do
      status.should == 200
    end
  end
end
<commit_msg>[#27928633] api docs for publishing the insight<commit_after>require 'spec_helper'

resource "Insights" do
  let(:user) { users(:owner) }
  let(:note) { Events::NoteOnGreenplumInstance.last }
  let(:note_on_workspace) { Events::NoteOnWorkspace.first }

  before do
    log_in user
    note_on_workspace.insight = true
    note_on_workspace.save!
  end

  post "/insights/promote" do
    parameter :note_id, "Id of the Note being promoted"

    let(:note_id) { note.id }

    example_request "promote the note to insight" do
      status.should == 201
    end
  end

  post "/insights/publish" do
    parameter :note_id, "Id of the Note being promoted"

    let(:note_id) {note_on_workspace.id}

    example_request "publish the insight" do
      status.should == 201
    end
  end

  get "/insights" do
    parameter :entity_id, "Entity Id for filtering insights"
    parameter :entity_type, "Entity_type (dashboard or workspace)"

    required_parameters :entity_type

    let(:entity_type) {"workspace"}
    let(:entity_id) {1}

    example_request "get the list of insights" do
      status.should == 200
    end
  end

  get "/insights/count" do

    parameter :entity_id, "Entity Id for filtering insights"
    parameter :entity_type, "Entity_type (dashboard or workspace)"

    required_parameters :entity_type

    let(:entity_type) {"dashboard"}
    example_request "get the number of insights" do
      status.should == 200
    end
  end
end

{'fraction_non_alphanumeric': 0.0925999208547685, 'fraction_numerical': 0.01226751088246933, 'mean_word_length': 3.4041811846689893, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7462480', 'n_tokens_mistral': 824, 'n_tokens_neox': 771, 'n_words': 239}