1- # -*- coding: utf-8 -*-
1+ # -*- coding: utf-8 -*-
22from __future__ import unicode_literals
33
4+ from tqdm import tqdm
45from django .db import migrations , models
56
67def port_rules_to_typed_system (apps , schema_editor ):
@@ -21,7 +22,11 @@ def try_to_uniquify_person(rule, person_qs):
2122 return person_qs
2223
2324
24- for rule in SearchRule .objects .all ().iterator ():
25+ print ("" )
26+ print (" * Port Rules to Typed System" )
27+ print (" Expect an initial rule count of around 550 here, as of May 2016:" )
28+ print (" rule count: %s" % SearchRule .objects .all ().count ())
29+ for rule in tqdm (SearchRule .objects .all ()):
2530 handled = False
2631
2732 if rule .rule_type in ['wg_asociated' , 'area_asociated' , 'wg_asociated_rfc' , 'area_asociated_rfc' ]:
@@ -112,10 +117,14 @@ def try_to_uniquify_person(rule, person_qs):
112117 else :
113118 rule .delete ()
114119 #print "NOT HANDLED", rule.pk, rule.rule_type, rule.value
120+ print (" rule count: %s" % SearchRule .objects .all ().count ())
115121
116122def delete_extra_person_rules (apps , schema_editor ):
117123 SearchRule = apps .get_model ("community" , "SearchRule" )
124+ print ("" )
125+ print (" * Delete Extra Person Rules" )
118126 SearchRule .objects .exclude (person = None ).filter (value = "" ).delete ()
127+ print (" rule count: %s" % SearchRule .objects .all ().count ())
119128
120129RENAMED_RULES = [
121130 ('wg_asociated' , 'group' ),
@@ -141,25 +150,33 @@ def rename_rule_type_forwards(apps, schema_editor):
141150
142151 renamings = dict (RENAMED_RULES )
143152
144- for r in SearchRule .objects .all ():
153+ print ("" )
154+ print (" * Rename Rule Type Forwards" )
155+ for r in tqdm (SearchRule .objects .all ()):
145156 if r .rule_type in renamings :
146157 r .rule_type = renamings [r .rule_type ]
147158 r .save ()
159+ print (" rule count: %s" % SearchRule .objects .all ().count ())
148160
149161def rename_rule_type_backwards (apps , schema_editor ):
150162 SearchRule = apps .get_model ("community" , "SearchRule" )
151163
152164 renamings = dict ((to , fro ) for fro , to in RENAMED_RULES )
153165
154- for r in SearchRule .objects .all ():
166+ print ("" )
167+ print (" * Rename Rule Type Backwards" )
168+ for r in tqdm (SearchRule .objects .all ()):
155169 if r .rule_type in renamings :
156170 r .rule_type = renamings [r .rule_type ]
157171 r .save ()
172+ print (" rule count: %s" % SearchRule .objects .all ().count ())
158173
159174def get_rid_of_empty_lists (apps , schema_editor ):
160175 CommunityList = apps .get_model ("community" , "CommunityList" )
161176
162- for cl in CommunityList .objects .all ():
177+ print ("" )
178+ print (" * Get Rid of Empty Lists" )
179+ for cl in tqdm (CommunityList .objects .all ()):
163180 if not cl .added_docs .exists () and not cl .searchrule_set .exists () and not cl .emailsubscription_set .exists ():
164181 cl .delete ()
165182
@@ -168,7 +185,9 @@ def move_email_subscriptions_to_preregistered_email(apps, schema_editor):
168185 Email = apps .get_model ("person" , "Email" )
169186 Person = apps .get_model ("person" , "Person" )
170187
171- for e in EmailSubscription .objects .all ():
188+ print ("" )
189+ print (" * Move Email Subscriptions to Preregistered Email" )
190+ for e in tqdm (EmailSubscription .objects .all ()):
172191 email_obj = None
173192 try :
174193 email_obj = Email .objects .get (address = e .email )
@@ -191,6 +210,8 @@ def move_email_subscriptions_to_preregistered_email(apps, schema_editor):
191210def fill_in_notify_on (apps , schema_editor ):
192211 EmailSubscription = apps .get_model ("community" , "EmailSubscription" )
193212
213+ # print("")
214+ # print(" * Fill In Notify On")
194215 EmailSubscription .objects .filter (significant = False , notify_on = "all" )
195216 EmailSubscription .objects .filter (significant = True , notify_on = "significant" )
196217
@@ -204,7 +225,9 @@ def add_group_community_lists(apps, schema_editor):
204225 active_state = State .objects .get (slug = "active" , type = "draft" )
205226 rfc_state = State .objects .get (slug = "rfc" , type = "draft" )
206227
207- for g in Group .objects .filter (type__in = ("rg" , "wg" )):
228+ print ("" )
229+ print (" * Add Group Community Lists" )
230+ for g in tqdm (Group .objects .filter (type__in = ("rg" , "wg" ))):
208231 clist = CommunityList .objects .filter (group = g ).first ()
209232 if clist :
210233 SearchRule .objects .get_or_create (community_list = clist , rule_type = "group" , group = g , state = active_state )
@@ -218,6 +241,7 @@ def add_group_community_lists(apps, schema_editor):
218241 SearchRule .objects .create (community_list = clist , rule_type = "group_rfc" , group = g , state = rfc_state )
219242 r = SearchRule .objects .create (community_list = clist , rule_type = "name_contains" , text = r"^draft-[^-]+-%s-" % g .acronym , state = active_state )
220243 r .name_contains_index = Document .objects .filter (docalias__name__regex = r .text )
244+ print (" rule count: %s" % SearchRule .objects .all ().count ())
221245
222246def noop (apps , schema_editor ):
223247 pass
0 commit comments