<commit_before>module Hypgen
  module Api
    module V1
      class ThreatAssessments < Grape::API

        resource :threat_assessments do
          get do
            { help: 'REST interface for starting ISMOP threat assessment'}
          end

          params do
            requires :threat_assessment, type: Hash  do
              requires :name, type: String
              requires :section_ids, type: Array
              requires :start_date, type: Time
              requires :end_date, type: Time
              optional :deadline, type: Integer, default: 500
            end
          end
          post do
            exp = Hypgen::Experiment.new(
              params[:threat_assessment][:name],
              params[:threat_assessment][:section_ids],
              params[:threat_assessment][:start_date],
              params[:threat_assessment][:end_date],
              params[:threat_assessment][:deadline])

            exp.start!

            status 201
            {
              meta: {
                url: "#{Hypgen.config.dap_url}/api/v1/threat_assessments/#{exp.id}"
              },
              threat_assessment: {
                id: exp.id
              }
            }
          end
        end
      end
    end
  end
end<commit_msg>Fix url returned by threat_assessment service.<commit_after>module Hypgen
  module Api
    module V1
      class ThreatAssessments < Grape::API

        resource :threat_assessments do
          get do
            { help: 'REST interface for starting ISMOP threat assessment'}
          end

          params do
            requires :threat_assessment, type: Hash  do
              requires :name, type: String
              requires :section_ids, type: Array
              requires :start_date, type: Time
              requires :end_date, type: Time
              optional :deadline, type: Integer, default: 500
            end
          end
          post do
            exp = Hypgen::Experiment.new(
              params[:threat_assessment][:name],
              params[:threat_assessment][:section_ids],
              params[:threat_assessment][:start_date],
              params[:threat_assessment][:end_date],
              params[:threat_assessment][:deadline])

            exp.start!

            status 201
            {
              meta: {
                url: "#{Hypgen.config.dap_url}/api/v1/threat_assessment_runs/#{exp.id}"
              },
              threat_assessment: {
                id: exp.id
              }
            }
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07895760404511863, 'fraction_numerical': 0.006223259432127577, 'mean_word_length': 1.433301797540208, 'pattern_counts': {'":': 0, '<': 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': '3091666', 'n_tokens_mistral': 699, 'n_tokens_neox': 650, 'n_words': 160}