Merge pull request #1178 from okriuchykhin/ok_SCI_2462

Add user id tracking when discarding repository [SCI-2462]
This commit is contained in:
okriuchykhin 2018-05-30 10:23:17 +02:00 committed by GitHub
commit 3253cac86f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 13 deletions

View file

@ -74,7 +74,7 @@ class RepositoriesController < ApplicationController
flash[:success] = t('repositories.index.delete_flash',
name: @repository.name)
@repository.discard
ClearDiscardedRepositoriesJob.perform_later
@repository.destroy_discarded(current_user.id)
redirect_to team_repositories_path
end

View file

@ -1,11 +0,0 @@
class ClearDiscardedRepositoriesJob
class << self
def perform_later
Repository.with_discarded.discarded.destroy_all
end
handle_asynchronously :perform_later,
queue: :clear_discarded_repositories,
priority: 20
end
end

View file

@ -2,7 +2,9 @@ class Repository < ApplicationRecord
include SearchableModel
include RepositoryImportParser
include Discard::Model
attribute :discarded_by_id, :integer
belongs_to :team, optional: true
belongs_to :created_by,
foreign_key: :created_by_id,
@ -107,4 +109,12 @@ class Repository < ApplicationRecord
importer = RepositoryImportParser::Importer.new(sheet, mappings, user, self)
importer.run
end
def destroy_discarded(discarded_by_id = nil)
self.discarded_by_id = discarded_by_id
destroy
end
handle_asynchronously :destroy_discarded,
queue: :clear_discarded_repository,
priority: 20
end