<commit_before>class SystemHooksService
  def self.execute_hooks_for(model, event)
    execute_hooks(build_event_data(model, event))
  end

  private

  def self.execute_hooks(data)
    SystemHook.all.each do |sh|
      async_execute_hook sh, data
    end
  end

  def self.async_execute_hook(hook, data)
    Sidekiq::Client.enqueue(SystemHookWorker, hook.id, data)
  end

  def self.build_event_data(model, event)
    data = {
      event_name: build_event_name(model, event),
      created_at: model.created_at
    }

    case model
    when Project
      data.merge!({
        name: model.name,
        path: model.path_with_namespace,
        project_id: model.id,
        owner_name: model.owner.name,
        owner_email: model.owner.email
      })
    when User
      data.merge!({
        name: model.name,
        email: model.email
      })
    when UsersProject
      data.merge!({
        project_name: model.project.name,
        project_path: model.project.path,
        project_id: model.project_id,
        user_name: model.user.name,<commit_msg>Use separate property for project path and project path with namespace inside system hook<commit_after>class SystemHooksService
  def self.execute_hooks_for(model, event)
    execute_hooks(build_event_data(model, event))
  end

  private

  def self.execute_hooks(data)
    SystemHook.all.each do |sh|
      async_execute_hook sh, data
    end
  end

  def self.async_execute_hook(hook, data)
    Sidekiq::Client.enqueue(SystemHookWorker, hook.id, data)
  end

  def self.build_event_data(model, event)
    data = {
      event_name: build_event_name(model, event),
      created_at: model.created_at
    }

    case model
    when Project
      data.merge!({
        name: model.name,
        path: model.path,
        path_with_namespace: model.path_with_namespace,
        project_id: model.id,
        owner_name: model.owner.name,
        owner_email: model.owner.email
      })
    when User
      data.merge!({
        name: model.name,
        email: model.email
      })
    when UsersProject
      data.merge!({
        project_name: model.project.name,
        project_path: model.project.path,
        project_id: model.project_id,
        user_name: model.user.name,
{'fraction_non_alphanumeric': 0.08879964301651048, 'fraction_numerical': 0.0, 'mean_word_length': 2.621970920840065, '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': '3729419', 'n_tokens_mistral': 712, 'n_tokens_neox': 707, 'n_words': 150}