Commit b29124b1 authored by Nicolas Dular's avatar Nicolas Dular

Record onboarding action for issue creation

This records an onboarding progress action for a namespace when an issue
got created.
parent cd40c625
......@@ -17,6 +17,7 @@ class OnboardingProgress < ApplicationRecord
:code_owners_enabled,
:scoped_label_created,
:security_scan_enabled,
:issue_created,
:issue_auto_closed,
:repository_imported,
:repository_mirrored
......
......@@ -28,6 +28,7 @@ module Issues
issue.run_after_commit do
NewIssueWorker.perform_async(issue.id, user.id)
IssuePlacementWorker.perform_async(nil, issue.project_id)
Namespaces::OnboardingIssueCreatedWorker.perform_async(issue.namespace.id)
end
end
......
......@@ -1840,6 +1840,14 @@
:weight: 1
:idempotent:
:tags: []
- :name: namespaces_onboarding_issue_created
:feature_category: :issue_tracking
:has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
:weight: 1
:idempotent: true
:tags: []
- :name: namespaces_onboarding_pipeline_created
:feature_category: :subgroups
:has_external_dependencies:
......
# frozen_string_literal: true
module Namespaces
class OnboardingIssueCreatedWorker
include ApplicationWorker
feature_category :issue_tracking
urgency :low
deduplicate :until_executing
idempotent!
def perform(namespace_id)
namespace = Namespace.find_by_id(namespace_id)
return unless namespace
OnboardingProgressService.new(namespace).execute(action: :issue_created)
end
end
end
---
title: Record onboarding action for issue creation
merge_request: 53611
author:
type: changed
......@@ -212,6 +212,8 @@
- 1
- - namespaceless_project_destroy
- 1
- - namespaces_onboarding_issue_created
- 1
- - namespaces_onboarding_pipeline_created
- 1
- - namespaces_onboarding_progress
......
# frozen_string_literal: true
class AddIssueCreatedAtToOnboardingProgress < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :onboarding_progresses, :issue_created_at, :datetime_with_timezone
end
end
039962e291f9adde52379cac8f8278aa1b339d973fb33ae40ea7d8dc3e113fb6
\ No newline at end of file
......@@ -14694,7 +14694,8 @@ CREATE TABLE onboarding_progresses (
security_scan_enabled_at timestamp with time zone,
issue_auto_closed_at timestamp with time zone,
repository_imported_at timestamp with time zone,
repository_mirrored_at timestamp with time zone
repository_mirrored_at timestamp with time zone,
issue_created_at timestamp with time zone
);
CREATE SEQUENCE onboarding_progresses_id_seq
......@@ -286,6 +286,12 @@ RSpec.describe Issues::CreateService do
issue
end
it 'schedules a namespace onboarding create action worker' do
expect(Namespaces::OnboardingIssueCreatedWorker).to receive(:perform_async).with(project.namespace.id)
issue
end
end
context 'issue create service' do
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Namespaces::OnboardingIssueCreatedWorker, '#perform' do
let_it_be(:issue) { create(:issue) }
let(:namespace) { issue.namespace }
it_behaves_like 'records an onboarding progress action', :issue_created do
subject { described_class.new.perform(namespace.id) }
end
it_behaves_like 'does not record an onboarding progress action' do
subject { described_class.new.perform(nil) }
end
it_behaves_like 'an idempotent worker' do
let(:job_args) { [namespace.id] }
it 'sets the onboarding progress action' do
OnboardingProgress.onboard(namespace)
subject
expect(OnboardingProgress.completed?(namespace, :issue_created)).to eq(true)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment