Refactoring: Migrated LDAP and Excachange statistics to new sum/total structure for clearer results and better performance.
This commit is contained in:
parent
f0cf7c3605
commit
e37328d201
12 changed files with 42 additions and 69 deletions
|
@ -131,13 +131,12 @@ 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
|
|
||||||
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
|
||||||
role = App.Role.find(role_id)
|
role = App.Role.find(role_id)
|
||||||
job.result.roles[role.displayName()] = statistic
|
job.result.roles[role.displayName()] = statistic
|
||||||
el = $(App.view('integration/exchange_last_import')(job: job, countDone: countDone))
|
el = $(App.view('integration/exchange_last_import')(job: job))
|
||||||
@lastImport.html(el)
|
@lastImport.html(el)
|
||||||
|
|
||||||
activeDryRun: =>
|
activeDryRun: =>
|
||||||
|
@ -540,34 +539,26 @@ class ConnectionWizard extends App.WizardModal
|
||||||
@showAlert('js-error', (job.result.error || job.result.info))
|
@showAlert('js-error', (job.result.error || job.result.info))
|
||||||
return
|
return
|
||||||
|
|
||||||
total = 0
|
|
||||||
if job.result && _.keys(job.result).length > 0
|
if job.result && _.keys(job.result).length > 0
|
||||||
@$('.js-preprogress').addClass('hide')
|
@$('.js-preprogress').addClass('hide')
|
||||||
@$('.js-analyzing').removeClass('hide')
|
@$('.js-analyzing').removeClass('hide')
|
||||||
|
|
||||||
analized = 0
|
@$('.js-progress progress').attr('value', job.result.sum)
|
||||||
total = job.result.sum
|
@$('.js-progress progress').attr('max', job.result.total)
|
||||||
for action, sum of job.result
|
|
||||||
continue if action == 'folders'
|
|
||||||
continue if action == 'sum'
|
|
||||||
analized += sum
|
|
||||||
|
|
||||||
@$('.js-progress progress').attr('value', analized)
|
|
||||||
@$('.js-progress progress').attr('max', total)
|
|
||||||
|
|
||||||
if job.finished_at
|
if job.finished_at
|
||||||
# reset initial state in case the back button is used
|
# reset initial state in case the back button is used
|
||||||
@$('.js-preprogress').removeClass('hide')
|
@$('.js-preprogress').removeClass('hide')
|
||||||
@$('.js-analyzing').addClass('hide')
|
@$('.js-analyzing').addClass('hide')
|
||||||
|
|
||||||
@tryResult(job, total)
|
@tryResult(job)
|
||||||
else
|
else
|
||||||
@delay(@tryLoop, 4000)
|
@delay(@tryLoop, 4000)
|
||||||
)
|
)
|
||||||
|
|
||||||
tryResult: (job, total) =>
|
tryResult: (job) =>
|
||||||
@showSlide('js-try')
|
@showSlide('js-try')
|
||||||
el = $(App.view('integration/exchange_summary')(job: job, countDone: total))
|
el = $(App.view('integration/exchange_summary')(job: job))
|
||||||
@el.find('.js-summary').html(el)
|
@el.find('.js-summary').html(el)
|
||||||
|
|
||||||
App.Config.set(
|
App.Config.set(
|
||||||
|
|
|
@ -132,13 +132,12 @@ 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
|
|
||||||
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
|
||||||
role = App.Role.find(role_id)
|
role = App.Role.find(role_id)
|
||||||
job.result.roles[role.displayName()] = statistic
|
job.result.roles[role.displayName()] = statistic
|
||||||
el = $(App.view('integration/ldap_last_import')(job: job, countDone: countDone))
|
el = $(App.view('integration/ldap_last_import')(job: job))
|
||||||
@lastImport.html(el)
|
@lastImport.html(el)
|
||||||
|
|
||||||
activeDryRun: =>
|
activeDryRun: =>
|
||||||
|
@ -539,22 +538,12 @@ class ConnectionWizard extends App.WizardModal
|
||||||
@showAlert('js-error', (job.result.error || job.result.info))
|
@showAlert('js-error', (job.result.error || job.result.info))
|
||||||
return
|
return
|
||||||
|
|
||||||
if job.result && job.result.sum
|
if job.result && job.result.total
|
||||||
@$('.js-preprogress').addClass('hide')
|
@$('.js-preprogress').addClass('hide')
|
||||||
@$('.js-analyzing').removeClass('hide')
|
@$('.js-analyzing').removeClass('hide')
|
||||||
total = 0
|
|
||||||
if job.result.created
|
@$('.js-progress progress').attr('value', job.result.sum)
|
||||||
total += job.result.created
|
@$('.js-progress progress').attr('max', job.result.total)
|
||||||
if job.result.failed
|
|
||||||
total += job.result.failed
|
|
||||||
if job.result.skipped
|
|
||||||
total += job.result.skipped
|
|
||||||
if job.result.unchanged
|
|
||||||
total += job.result.unchanged
|
|
||||||
if job.result.updated
|
|
||||||
total += job.result.updated
|
|
||||||
@$('.js-progress progress').attr('value', total)
|
|
||||||
@$('.js-progress progress').attr('max', job.result.sum)
|
|
||||||
if job.finished_at
|
if job.finished_at
|
||||||
# reset initial state in case the back button is used
|
# reset initial state in case the back button is used
|
||||||
@$('.js-preprogress').removeClass('hide')
|
@$('.js-preprogress').removeClass('hide')
|
||||||
|
@ -574,9 +563,8 @@ 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
|
|
||||||
@showSlide('js-try')
|
@showSlide('js-try')
|
||||||
el = $(App.view('integration/ldap_summary')(job: job, countDone: countDone))
|
el = $(App.view('integration/ldap_summary')(job: job))
|
||||||
@el.find('.js-summary').html(el)
|
@el.find('.js-summary').html(el)
|
||||||
|
|
||||||
App.Config.set(
|
App.Config.set(
|
||||||
|
|
|
@ -20,18 +20,18 @@
|
||||||
<% if @job.result && @job.result.error: %>
|
<% if @job.result && @job.result.error: %>
|
||||||
<p><%- @Ttimestamp(@job.started_at) %></p>
|
<p><%- @Ttimestamp(@job.started_at) %></p>
|
||||||
<div class="alert alert--danger" role="alert"><%- @T('An error occurred: %s', @job.result.error) %></div>
|
<div class="alert alert--danger" role="alert"><%- @T('An error occurred: %s', @job.result.error) %></div>
|
||||||
<% else if !@countDone: %>
|
<% else if @job.result && !@job.result.sum: %>
|
||||||
<p><%- @Ttimestamp(@job.started_at) %> - <%- @T('Counting entries. This may take a while.') %></p>
|
<p><%- @Ttimestamp(@job.started_at) %> - <%- @T('Counting entries. This may take a while.') %></p>
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<p><%- @Ttimestamp(@job.started_at) %> - <%- @T('Running...') %></p>
|
<p><%- @Ttimestamp(@job.started_at) %> - <%- @T('Running...') %></p>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<progress max="<%= @job.result.sum %>" value="<%= @countDone %>"></progress>
|
<progress max="<%= @job.result.total %>" value="<%= @job.result.sum %>"></progress>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if !_.isEmpty(@job.result) && @countDone: %>
|
<% if !_.isEmpty(@job.result) && @job.result.sum: %>
|
||||||
<ul>
|
<ul>
|
||||||
<li><%- @T('%s user to %s user', 'Exchange', 'Zammad') %> (<%= @countDone %>/<%= @job.result.sum %>):
|
<li><%- @T('%s user to %s user', 'Exchange', 'Zammad') %> (<%= @job.result.sum %>/<%= @job.result.total %>):
|
||||||
<ul>
|
<ul>
|
||||||
<li><%- @T('Users') %>: <%= @job.result.created %> <%- @T('created') %>, <%= @job.result.updated %> <%- @T('updated') %>, <%= @job.result.unchanged %> <%- @T('untouched') %>, <%= @job.result.skipped %> <%- @T('skipped') %>, <%= @job.result.failed %> <%- @T('failed') %>
|
<li><%- @T('Users') %>: <%= @job.result.created %> <%- @T('created') %>, <%= @job.result.updated %> <%- @T('updated') %>, <%= @job.result.unchanged %> <%- @T('untouched') %>, <%= @job.result.skipped %> <%- @T('skipped') %>, <%= @job.result.failed %> <%- @T('failed') %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li><%- @T('%s user to %s user', 'Exchange', 'Zammad') %> (<%= @countDone %>):
|
<li><%- @T('%s user to %s user', 'Exchange', 'Zammad') %> (<%= @job.result.total %>):
|
||||||
<ul>
|
<ul>
|
||||||
<li><%- @T('Users') %>: <%= @job.result.created %> <%- @T('created') %>, <%= @job.result.updated %> <%- @T('updated') %>, <%= @job.result.unchanged %> <%- @T('untouched') %>, <%= @job.result.skipped %> <%- @T('skipped') %>, <%= @job.result.failed %> <%- @T('failed') %>
|
<li><%- @T('Users') %>: <%= @job.result.created %> <%- @T('created') %>, <%= @job.result.updated %> <%- @T('updated') %>, <%= @job.result.unchanged %> <%- @T('untouched') %>, <%= @job.result.skipped %> <%- @T('skipped') %>, <%= @job.result.failed %> <%- @T('failed') %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -20,18 +20,18 @@
|
||||||
<% if @job.result && @job.result.error: %>
|
<% if @job.result && @job.result.error: %>
|
||||||
<p><%- @Ttimestamp(@job.started_at) %></p>
|
<p><%- @Ttimestamp(@job.started_at) %></p>
|
||||||
<div class="alert alert--danger" role="alert"><%- @T('An error occurred: %s', @job.result.error) %></div>
|
<div class="alert alert--danger" role="alert"><%- @T('An error occurred: %s', @job.result.error) %></div>
|
||||||
<% else if !@countDone: %>
|
<% else if !@job.result.sum: %>
|
||||||
<p><%- @Ttimestamp(@job.started_at) %> - <%- @T('Counting entries. This may take a while.') %></p>
|
<p><%- @Ttimestamp(@job.started_at) %> - <%- @T('Counting entries. This may take a while.') %></p>
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<p><%- @Ttimestamp(@job.started_at) %> - <%- @T('Running...') %></p>
|
<p><%- @Ttimestamp(@job.started_at) %> - <%- @T('Running...') %></p>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<progress max="<%= @job.result.sum %>" value="<%= @countDone %>"></progress>
|
<progress max="<%= @job.result.total %>" value="<%= @job.result.sum %>"></progress>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if !_.isEmpty(@job.result) && @countDone: %>
|
<% if !_.isEmpty(@job.result) && @job.result.sum: %>
|
||||||
<ul>
|
<ul>
|
||||||
<li><%- @T('%s user to %s user', 'LDAP', 'Zammad') %> (<%= @countDone %>/<%= @job.result.sum %>):
|
<li><%- @T('%s user to %s user', 'LDAP', 'Zammad') %> (<%= @job.result.sum %>/<%= @job.result.total %>):
|
||||||
<ul>
|
<ul>
|
||||||
<li><%- @T('Users') %>: <%= @job.result.created %> <%- @T('created') %>, <%= @job.result.updated %> <%- @T('updated') %>, <%= @job.result.unchanged %> <%- @T('untouched') %>, <%= @job.result.skipped %> <%- @T('skipped') %>, <%= @job.result.failed %> <%- @T('failed') %>, <%= @job.result.deactivated %> <%- @T('deactivated') %>
|
<li><%- @T('Users') %>: <%= @job.result.created %> <%- @T('created') %>, <%= @job.result.updated %> <%- @T('updated') %>, <%= @job.result.unchanged %> <%- @T('untouched') %>, <%= @job.result.skipped %> <%- @T('skipped') %>, <%= @job.result.failed %> <%- @T('failed') %>, <%= @job.result.deactivated %> <%- @T('deactivated') %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li><%- @T('%s user to %s user', 'LDAP', 'Zammad') %> (<%= @countDone %>):
|
<li><%- @T('%s user to %s user', 'LDAP', 'Zammad') %> (<%= @job.result.sum %>):
|
||||||
<ul>
|
<ul>
|
||||||
<li><%- @T('Users') %>: <%= @job.result.created %> <%- @T('created') %>, <%= @job.result.updated %> <%- @T('updated') %>, <%= @job.result.unchanged %> <%- @T('untouched') %>, <%= @job.result.skipped %> <%- @T('skipped') %>, <%= @job.result.failed %> <%- @T('failed') %>, <%= @job.result.deactivated %> <%- @T('deactivated') %>
|
<li><%- @T('Users') %>: <%= @job.result.created %> <%- @T('created') %>, <%= @job.result.updated %> <%- @T('updated') %>, <%= @job.result.unchanged %> <%- @T('untouched') %>, <%= @job.result.skipped %> <%- @T('skipped') %>, <%= @job.result.failed %> <%- @T('failed') %>, <%= @job.result.deactivated %> <%- @T('deactivated') %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Sequencer
|
||||||
'Import::Exchange::FolderContacts::DryRunPayload',
|
'Import::Exchange::FolderContacts::DryRunPayload',
|
||||||
'Exchange::Connection',
|
'Exchange::Connection',
|
||||||
'Import::Exchange::FolderContacts::FolderIds',
|
'Import::Exchange::FolderContacts::FolderIds',
|
||||||
'Import::Exchange::FolderContacts::Sum',
|
'Import::Exchange::FolderContacts::Total',
|
||||||
'Import::Common::ImportJob::Statistics::Update',
|
'Import::Common::ImportJob::Statistics::Update',
|
||||||
'Import::Common::ImportJob::Statistics::Store',
|
'Import::Common::ImportJob::Statistics::Store',
|
||||||
'Import::Exchange::FolderContacts::SubSequence',
|
'Import::Exchange::FolderContacts::SubSequence',
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Sequencer
|
||||||
'Ldap::Config',
|
'Ldap::Config',
|
||||||
'Ldap::Connection',
|
'Ldap::Connection',
|
||||||
'Import::Ldap::Users::UserRoles',
|
'Import::Ldap::Users::UserRoles',
|
||||||
'Import::Ldap::Users::Sum',
|
'Import::Ldap::Users::Total',
|
||||||
'Import::Common::ImportJob::Statistics::Update',
|
'Import::Common::ImportJob::Statistics::Update',
|
||||||
'Import::Common::ImportJob::Statistics::Store',
|
'Import::Common::ImportJob::Statistics::Store',
|
||||||
'Import::Ldap::Users::SubSequence',
|
'Import::Ldap::Users::SubSequence',
|
||||||
|
|
|
@ -11,15 +11,11 @@ class Sequencer
|
||||||
|
|
||||||
def process
|
def process
|
||||||
state.provide(:statistics_diff) do
|
state.provide(:statistics_diff) do
|
||||||
# remove :sum since it's already set via
|
|
||||||
# the exchange item attribute
|
|
||||||
result = diff.except(:sum)
|
|
||||||
|
|
||||||
# build structure for a general diff
|
# build structure for a general diff
|
||||||
# and a folder specific sub structure
|
# and a folder specific sub structure
|
||||||
result.merge(
|
diff.merge(
|
||||||
folders: {
|
folders: {
|
||||||
ews_folder_name => result
|
ews_folder_name => diff
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,8 +3,9 @@ class Sequencer
|
||||||
module Import
|
module Import
|
||||||
module Exchange
|
module Exchange
|
||||||
module FolderContacts
|
module FolderContacts
|
||||||
class Sum < Sequencer::Unit::Base
|
class Total < Sequencer::Unit::Base
|
||||||
include ::Sequencer::Unit::Exchange::Folders::Mixin::Folder
|
include ::Sequencer::Unit::Exchange::Folders::Mixin::Folder
|
||||||
|
include ::Sequencer::Unit::Import::Common::Model::Statistics::Mixin::Common
|
||||||
|
|
||||||
uses :ews_folder_ids
|
uses :ews_folder_ids
|
||||||
provides :statistics_diff
|
provides :statistics_diff
|
||||||
|
@ -16,21 +17,22 @@ class Sequencer
|
||||||
private
|
private
|
||||||
|
|
||||||
def diff
|
def diff
|
||||||
result = {
|
result = empty_diff.merge(
|
||||||
sum: 0,
|
folders: {},
|
||||||
}
|
)
|
||||||
folder_sum_map.each do |display_path, sum|
|
|
||||||
|
|
||||||
result[display_path] = {
|
folder_total_map.each do |display_path, total|
|
||||||
sum: sum
|
|
||||||
}
|
|
||||||
|
|
||||||
result[:sum] += sum
|
result[:folders][display_path] = empty_diff.merge(
|
||||||
|
total: total
|
||||||
|
)
|
||||||
|
|
||||||
|
result[:total] += total
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def folder_sum_map
|
def folder_total_map
|
||||||
ews_folder_ids.collect do |folder_id|
|
ews_folder_ids.collect do |folder_id|
|
||||||
folder = ews_folder.find(folder_id)
|
folder = ews_folder.find(folder_id)
|
||||||
display_path = ews_folder.display_path(folder)
|
display_path = ews_folder.display_path(folder)
|
|
@ -13,11 +13,7 @@ class Sequencer
|
||||||
|
|
||||||
def process
|
def process
|
||||||
state.provide(:statistics_diff) do
|
state.provide(:statistics_diff) do
|
||||||
# remove :sum since it's already set via
|
add_role_ids(diff)
|
||||||
# the outer count Unit
|
|
||||||
statistics = diff.except(:sum)
|
|
||||||
|
|
||||||
add_role_ids(statistics)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Sequencer
|
||||||
module Import
|
module Import
|
||||||
module Ldap
|
module Ldap
|
||||||
module Users
|
module Users
|
||||||
class Sum < Sequencer::Unit::Base
|
class Total < Sequencer::Unit::Base
|
||||||
include ::Sequencer::Unit::Import::Common::Model::Statistics::Mixin::EmptyDiff
|
include ::Sequencer::Unit::Import::Common::Model::Statistics::Mixin::EmptyDiff
|
||||||
|
|
||||||
uses :ldap_config, :ldap_connection, :dry_run
|
uses :ldap_config, :ldap_connection, :dry_run
|
||||||
|
@ -13,14 +13,14 @@ class Sequencer
|
||||||
def process
|
def process
|
||||||
state.provide(:statistics_diff) do
|
state.provide(:statistics_diff) do
|
||||||
diff.merge(
|
diff.merge(
|
||||||
sum: sum
|
total: total
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def sum
|
def total
|
||||||
if !dry_run
|
if !dry_run
|
||||||
result = Cache.get(cache_key)
|
result = Cache.get(cache_key)
|
||||||
end
|
end
|
Loading…
Reference in a new issue