Working on issue #1211 - Improved output LDAP sync statistics for deactivated and skipped entries.
This commit is contained in:
parent
7ab4e7714b
commit
3c50f366f7
3 changed files with 22 additions and 15 deletions
|
@ -124,7 +124,7 @@ class Form extends App.Controller
|
||||||
if _.isEmpty(job)
|
if _.isEmpty(job)
|
||||||
@lastImport.html('')
|
@lastImport.html('')
|
||||||
return
|
return
|
||||||
countDone = job.result.created + job.result.updated + job.result.unchanged + job.result.skipped + job.result.failed + job.result.deactivated
|
countDone = job.result.created + job.result.updated + job.result.unchanged + job.result.skipped + job.result.failed
|
||||||
if !job.result.roles
|
if !job.result.roles
|
||||||
job.result.roles = {}
|
job.result.roles = {}
|
||||||
for role_id, statistic of job.result.role_ids
|
for role_id, statistic of job.result.role_ids
|
||||||
|
@ -545,8 +545,6 @@ class ConnectionWizard extends App.WizardModal
|
||||||
total += job.result.unchanged
|
total += job.result.unchanged
|
||||||
if job.result.updated
|
if job.result.updated
|
||||||
total += job.result.updated
|
total += job.result.updated
|
||||||
if job.result.deactivated
|
|
||||||
total += job.result.deactivated
|
|
||||||
@$('.js-progress progress').attr('value', total)
|
@$('.js-progress progress').attr('value', total)
|
||||||
@$('.js-progress progress').attr('max', job.result.sum)
|
@$('.js-progress progress').attr('max', job.result.sum)
|
||||||
if job.finished_at
|
if job.finished_at
|
||||||
|
@ -568,7 +566,7 @@ class ConnectionWizard extends App.WizardModal
|
||||||
for role_id, statistic of job.result.role_ids
|
for role_id, statistic of job.result.role_ids
|
||||||
role = App.Role.find(role_id)
|
role = App.Role.find(role_id)
|
||||||
job.result.roles[role.displayName()] = statistic
|
job.result.roles[role.displayName()] = statistic
|
||||||
countDone = job.result.created + job.result.updated + job.result.unchanged + job.result.skipped + job.result.deactivated
|
countDone = job.result.created + job.result.updated + job.result.unchanged + job.result.skipped
|
||||||
@showSlide('js-try')
|
@showSlide('js-try')
|
||||||
el = $(App.view('integration/ldap_summary')(job: job, countDone: countDone))
|
el = $(App.view('integration/ldap_summary')(job: job, countDone: countDone))
|
||||||
@el.find('.js-summary').html(el)
|
@el.find('.js-summary').html(el)
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Import
|
||||||
@remote_id
|
@remote_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.lost_ids(found_remote_ids)
|
def self.lost_map(found_remote_ids)
|
||||||
ExternalSync.joins('INNER JOIN users ON (users.id = external_syncs.o_id)')
|
ExternalSync.joins('INNER JOIN users ON (users.id = external_syncs.o_id)')
|
||||||
.where(
|
.where(
|
||||||
source: source,
|
source: source,
|
||||||
|
@ -18,7 +18,6 @@ module Import
|
||||||
.pluck(:source_id, :o_id)
|
.pluck(:source_id, :o_id)
|
||||||
.to_h
|
.to_h
|
||||||
.except(*found_remote_ids)
|
.except(*found_remote_ids)
|
||||||
.values
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.deactivate_lost(lost_ids)
|
def self.deactivate_lost(lost_ids)
|
||||||
|
|
|
@ -33,6 +33,7 @@ module Import
|
||||||
relevant_attributes = config[:user_attributes].keys
|
relevant_attributes = config[:user_attributes].keys
|
||||||
relevant_attributes.push('dn')
|
relevant_attributes.push('dn')
|
||||||
|
|
||||||
|
@found_lost_remote_ids = []
|
||||||
@found_remote_ids = []
|
@found_remote_ids = []
|
||||||
@ldap.search(config[:user_filter], attributes: relevant_attributes) do |entry|
|
@ldap.search(config[:user_filter], attributes: relevant_attributes) do |entry|
|
||||||
backend_instance = create_instance(entry, config, user_roles, signup_role_ids, kargs)
|
backend_instance = create_instance(entry, config, user_roles, signup_role_ids, kargs)
|
||||||
|
@ -122,23 +123,32 @@ module Import
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.track_found_remote_ids(backend_instance)
|
def self.track_found_remote_ids(backend_instance)
|
||||||
|
remote_id = backend_instance.remote_id(nil)
|
||||||
@deactivation_actions ||= %i(skipped failed)
|
@deactivation_actions ||= %i(skipped failed)
|
||||||
return if @deactivation_actions.include?(backend_instance.action)
|
if @deactivation_actions.include?(backend_instance.action)
|
||||||
|
@found_lost_remote_ids.push(remote_id)
|
||||||
@found_remote_ids.push(backend_instance.remote_id(nil))
|
else
|
||||||
|
@found_remote_ids.push(remote_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.handle_lost
|
def self.handle_lost
|
||||||
backend_class = backend_class(nil)
|
backend_class = backend_class(nil)
|
||||||
lost_ids = backend_class.lost_ids(@found_remote_ids)
|
lost_map = backend_class.lost_map(@found_remote_ids)
|
||||||
|
|
||||||
# track disabled count and substract it from
|
# disabled count is tracked as a separate number
|
||||||
# skipped where they are logged till now
|
# since they don't have to be in the sum (e.g. deleted in LDAP)
|
||||||
@statistics[:deactivated] = lost_ids.size
|
@statistics[:deactivated] = lost_map.size
|
||||||
@statistics[:skipped] -= lost_ids.size
|
|
||||||
|
# skipped deactivated are those who
|
||||||
|
# were found, skipped and will get deactivated
|
||||||
|
skipped_deactivated = @found_lost_remote_ids & lost_map.keys
|
||||||
|
@statistics[:skipped] -= skipped_deactivated.size
|
||||||
|
|
||||||
# loop over every lost user ID and add the
|
# loop over every lost user ID and add the
|
||||||
# deactivated count to the statistics
|
# deactivated count to the statistics
|
||||||
|
lost_ids = lost_map.values
|
||||||
|
|
||||||
lost_ids.each do |user_id|
|
lost_ids.each do |user_id|
|
||||||
role_ids = ::User.joins(:roles)
|
role_ids = ::User.joins(:roles)
|
||||||
.where(id: user_id)
|
.where(id: user_id)
|
||||||
|
|
Loading…
Reference in a new issue