Class: Import::SourceUsers::GenerateCsvService
- Inherits:
-
Object
- Object
- Import::SourceUsers::GenerateCsvService
- Defined in:
- app/services/import/source_users/generate_csv_service.rb
Overview
This class generates CSV data for Import::SourceUser records associated with a namespace. This spreadsheet is filled in and re-uploaded to facilitate the user mapping flow.
Constant Summary collapse
- FILESIZE_LIMIT =
This is just to prevent any potential abuse. A test file with 20k rows comes in at 2.3MB. A 10MB file would be several tens of thousands, whereas we would rarely expect to exceed 10k rows.
10.megabytes
- COLUMN_MAPPING =
{ 'Source host' => 'source_hostname', 'Import type' => 'import_type', 'Source user identifier' => 'source_user_identifier', 'Source user name' => 'source_name', 'Source username' => 'source_username', 'GitLab username' => ->(_) { '' }, 'GitLab public email' => ->(_) { '' } }.freeze
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(namespace, current_user:) ⇒ GenerateCsvService
constructor
A new instance of GenerateCsvService.
Constructor Details
#initialize(namespace, current_user:) ⇒ GenerateCsvService
Returns a new instance of GenerateCsvService.
26 27 28 29 |
# File 'app/services/import/source_users/generate_csv_service.rb', line 26 def initialize(namespace, current_user:) @namespace = namespace @current_user = current_user end |
Instance Method Details
#execute ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/services/import/source_users/generate_csv_service.rb', line 31 def execute # We use :owner_access here because it's shared between GroupPolicy and # NamespacePolicy. return unless current_user.can?(:owner_access, namespace) return error_no_source_users if import_source_users.empty? ServiceResponse.success(payload: csv_data) end |