From ad1d95f2251a9013d9d2728b3884ce04bc639902 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Mon, 29 Dec 2008 11:40:48 -0300 Subject: [PATCH] ActionItem862: one enterprise at a time --- script/apply-template | 18 +++++++++++++++--- script/release-v0.13.0-ecosol | 9 ++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/script/apply-template b/script/apply-template index ee0f2bf..6a7b2ea 100755 --- a/script/apply-template +++ b/script/apply-template @@ -8,9 +8,21 @@ env = Environment.default case $ARGV[0] when 'inactive-enterprise' - inactive_enterprises = Enterprise.find(:all, :conditions => {:enabled => false}) - [env.inactive_enterprise_template, env.enterprise_template] - apply_in = inactive_enterprises[$ARGV[1].to_i..$ARGV[2].to_i] - apply_in.each_with_index { |obj,i| obj.apply_template(env.inactive_enterprise_template); puts i.to_s + ' - ' + obj.identifier} unless apply_in.nil? + offset = 0 + excluded = [env.inactive_enterprise_template, env.enterprise_template] + template = excluded.first + + while enterprise = Enterprise.find(:first, :conditions => {:enabled => false}, :offset => offset) + # do nothing with templates + next if excluded.include?(enterprise) + + # do the thing + enterprise.apply_template(template) + puts "#{offset} - #{enterprise.identifier}" + + # bring it on ... + offset = offset + 1 + end when 'active-enterprise' active_enterprises = Enterprise.find(:all, :conditions => {:enabled => true}) - [env.enterprise_template, env.enterprise_template] active_enterprises.each { |enterprise| enterprise.apply_template(env.enterprise_template) } diff --git a/script/release-v0.13.0-ecosol b/script/release-v0.13.0-ecosol index 86a5e01..e4360fc 100755 --- a/script/release-v0.13.0-ecosol +++ b/script/release-v0.13.0-ecosol @@ -58,13 +58,8 @@ script/runner 'env = Environment.default main.blocks << MainBlock.new template.save!' -echo 'Applying template for inactive enterprises (require bc calculator)...' -start=0; -for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21; do - end=`echo "$i * 1000" | bc`; - script/apply-template 'inactive-enterprise' $start $end; - start=$end; -done +echo 'Applying template for inactive enterprises' +script/apply-template 'inactive-enterprise' echo 'Applying template for active enterprises...' script/apply-template 'active-enterprise' -- libgit2 0.21.2