Class: Gitlab::BackgroundMigration::BackfillNewAuditEventTables
- Inherits:
-
BatchedMigrationJob
- Object
- BatchedMigrationJob
- Gitlab::BackgroundMigration::BackfillNewAuditEventTables
- Defined in:
- lib/gitlab/background_migration/backfill_new_audit_event_tables.rb
Constant Summary
Constants inherited from BatchedMigrationJob
Gitlab::BackgroundMigration::BatchedMigrationJob::DEFAULT_FEATURE_CATEGORY
Constants included from Database::DynamicModelHelpers
Database::DynamicModelHelpers::BATCH_SIZE
Instance Method Summary collapse
Methods inherited from BatchedMigrationJob
#batch_metrics, cursor, cursor?, cursor_columns, feature_category, #filter_batch, generic_instance, #initialize, job_arguments, job_arguments_count, operation_name, scope_to
Methods included from Database::DynamicModelHelpers
#define_batchable_model, #each_batch, #each_batch_range
Constructor Details
This class inherits a constructor from Gitlab::BackgroundMigration::BatchedMigrationJob
Instance Method Details
#perform ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gitlab/background_migration/backfill_new_audit_event_tables.rb', line 9 def perform each_sub_batch do |sub_batch| audit_events = sub_batch.pluck(:id, :created_at, :author_id, :target_id, :details, :ip_address, :author_name, :entity_path, :target_details, :target_type, :entity_id, :entity_type) project_audit_events = [] group_audit_events = [] user_audit_events = [] instance_audit_events = [] audit_events.each do |event| case event.last when 'Project' project_audit_events << event[0..-2] when 'Group' group_audit_events << event[0..-2] when 'User' user_audit_events << event[0..-2] when 'Gitlab::Audit::InstanceScope' instance_audit_events << event[0..-3] end end insert_project_audit_events(project_audit_events) insert_group_audit_events(group_audit_events) insert_user_audit_events(user_audit_events) insert_instance_audit_events(instance_audit_events) end end |