2025-02-15 12:49:30 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class Imports::Destroy
|
|
|
|
|
attr_reader :user, :import
|
|
|
|
|
|
|
|
|
|
def initialize(user, import)
|
|
|
|
|
@user = user
|
|
|
|
|
@import = import
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def call
|
2025-12-26 09:27:09 -05:00
|
|
|
points_count = @import.points_count
|
|
|
|
|
|
2025-05-31 15:27:20 -04:00
|
|
|
ActiveRecord::Base.transaction do
|
2025-12-26 09:27:09 -05:00
|
|
|
@import.points.destroy_all
|
2025-05-31 15:27:20 -04:00
|
|
|
@import.destroy!
|
|
|
|
|
end
|
2025-02-15 12:49:30 -05:00
|
|
|
|
2025-12-26 09:27:09 -05:00
|
|
|
Rails.logger.info "Import #{@import.id} deleted with #{points_count} points"
|
|
|
|
|
|
2025-04-03 12:41:05 -04:00
|
|
|
Stats::BulkCalculator.new(@user.id).call
|
2025-02-15 12:49:30 -05:00
|
|
|
end
|
|
|
|
|
end
|