From e37328d2019bc0fac17a30354dfbfe577f91921c Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 8 Jan 2018 16:30:09 +0100 Subject: [PATCH] Refactoring: Migrated LDAP and Excachange statistics to new sum/total structure for clearer results and better performance. --- .../controllers/_integration/exchange.coffee | 21 +++++----------- .../app/controllers/_integration/ldap.coffee | 24 +++++-------------- .../integration/exchange_last_import.jst.eco | 8 +++---- .../integration/exchange_summary.jst.eco | 2 +- .../integration/ldap_last_import.jst.eco | 8 +++---- .../views/integration/ldap_summary.jst.eco | 2 +- .../import/exchange/folder_contacts.rb | 2 +- lib/sequencer/sequence/import/ldap/users.rb | 2 +- .../folder_contact/statistics/diff.rb | 8 ++----- .../folder_contacts/{sum.rb => total.rb} | 22 +++++++++-------- .../unit/import/ldap/user/statistics/diff.rb | 6 +---- .../import/ldap/users/{sum.rb => total.rb} | 6 ++--- 12 files changed, 42 insertions(+), 69 deletions(-) rename lib/sequencer/unit/import/exchange/folder_contacts/{sum.rb => total.rb} (61%) rename lib/sequencer/unit/import/ldap/users/{sum.rb => total.rb} (91%) diff --git a/app/assets/javascripts/app/controllers/_integration/exchange.coffee b/app/assets/javascripts/app/controllers/_integration/exchange.coffee index c02c541ba..13ea97709 100644 --- a/app/assets/javascripts/app/controllers/_integration/exchange.coffee +++ b/app/assets/javascripts/app/controllers/_integration/exchange.coffee @@ -131,13 +131,12 @@ class Form extends App.Controller if _.isEmpty(job) @lastImport.html('') return - countDone = job.result.created + job.result.updated + job.result.unchanged + job.result.skipped + job.result.failed if !job.result.roles job.result.roles = {} for role_id, statistic of job.result.role_ids role = App.Role.find(role_id) 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) activeDryRun: => @@ -540,34 +539,26 @@ class ConnectionWizard extends App.WizardModal @showAlert('js-error', (job.result.error || job.result.info)) return - total = 0 if job.result && _.keys(job.result).length > 0 @$('.js-preprogress').addClass('hide') @$('.js-analyzing').removeClass('hide') - analized = 0 - total = job.result.sum - 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) + @$('.js-progress progress').attr('value', job.result.sum) + @$('.js-progress progress').attr('max', job.result.total) if job.finished_at # reset initial state in case the back button is used @$('.js-preprogress').removeClass('hide') @$('.js-analyzing').addClass('hide') - @tryResult(job, total) + @tryResult(job) else @delay(@tryLoop, 4000) ) - tryResult: (job, total) => + tryResult: (job) => @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) App.Config.set( diff --git a/app/assets/javascripts/app/controllers/_integration/ldap.coffee b/app/assets/javascripts/app/controllers/_integration/ldap.coffee index cd6312a68..3384980a9 100644 --- a/app/assets/javascripts/app/controllers/_integration/ldap.coffee +++ b/app/assets/javascripts/app/controllers/_integration/ldap.coffee @@ -132,13 +132,12 @@ class Form extends App.Controller if _.isEmpty(job) @lastImport.html('') return - countDone = job.result.created + job.result.updated + job.result.unchanged + job.result.skipped + job.result.failed if !job.result.roles job.result.roles = {} for role_id, statistic of job.result.role_ids role = App.Role.find(role_id) 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) activeDryRun: => @@ -539,22 +538,12 @@ class ConnectionWizard extends App.WizardModal @showAlert('js-error', (job.result.error || job.result.info)) return - if job.result && job.result.sum + if job.result && job.result.total @$('.js-preprogress').addClass('hide') @$('.js-analyzing').removeClass('hide') - total = 0 - if job.result.created - total += job.result.created - 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) + + @$('.js-progress progress').attr('value', job.result.sum) + @$('.js-progress progress').attr('max', job.result.total) if job.finished_at # reset initial state in case the back button is used @$('.js-preprogress').removeClass('hide') @@ -574,9 +563,8 @@ class ConnectionWizard extends App.WizardModal for role_id, statistic of job.result.role_ids role = App.Role.find(role_id) job.result.roles[role.displayName()] = statistic - countDone = job.result.created + job.result.updated + job.result.unchanged + job.result.skipped @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) App.Config.set( diff --git a/app/assets/javascripts/app/views/integration/exchange_last_import.jst.eco b/app/assets/javascripts/app/views/integration/exchange_last_import.jst.eco index 8323972ad..4ded44e85 100644 --- a/app/assets/javascripts/app/views/integration/exchange_last_import.jst.eco +++ b/app/assets/javascripts/app/views/integration/exchange_last_import.jst.eco @@ -20,18 +20,18 @@ <% if @job.result && @job.result.error: %>

<%- @Ttimestamp(@job.started_at) %>

- <% else if !@countDone: %> + <% else if @job.result && !@job.result.sum: %>

<%- @Ttimestamp(@job.started_at) %> - <%- @T('Counting entries. This may take a while.') %>

<% else: %>

<%- @Ttimestamp(@job.started_at) %> - <%- @T('Running...') %>

- +
<% end %> <% end %> - <% if !_.isEmpty(@job.result) && @countDone: %> + <% if !_.isEmpty(@job.result) && @job.result.sum: %>