Skip to content

Commit 74caa2e

Browse files
committed
Add date limiting parameter to importer to only grab documents with
last_modified_date within date, restrict authors to those documents and similar for meeting sessions - Legacy-Id: 3881
1 parent 987f91c commit 74caa2e

3 files changed

Lines changed: 30 additions & 7 deletions

File tree

redesign/importing/import-docs.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@
2727

2828
from workflows.models import State as StateOld
2929

30-
document_name_to_import = None
30+
import_docs_from = document_name_to_import = None
3131
if len(sys.argv) > 1:
32-
document_name_to_import = sys.argv[1]
32+
try:
33+
import_docs_from = datetime.datetime.strptime(sys.argv[1], "%Y-%m-%d")
34+
except:
35+
document_name_to_import = sys.argv[1]
3336

3437
dont_save_queries()
3538

@@ -225,6 +228,8 @@ def iesg_login_is_secretary(l):
225228
# Amy has two users, for some reason, we sometimes get the wrong one
226229
return l.user_level == IESGLogin.SECRETARIAT_LEVEL or (l.first_name == "Amy" and l.last_name == "Vezza")
227230

231+
old_internetdraft_content_type_id = ContentType.objects.using("legacy").get(app_label="idtracker", model="internetdraft").pk
232+
228233
# regexps for parsing document comments
229234

230235
date_re_str = "(?P<year>[0-9][0-9][0-9][0-9])-(?P<month>[0-9][0-9]?)-(?P<day>[0-9][0-9]?)"
@@ -765,15 +770,15 @@ def import_from_idinternal(d, idinternal):
765770

766771

767772
all_drafts = InternetDraft.objects.all().order_by('pk').select_related()
773+
if import_docs_from:
774+
all_drafts = all_drafts.filter(last_modified_date__gte=import_docs_from)
775+
768776
if document_name_to_import:
769777
if document_name_to_import.startswith("rfc"):
770778
all_drafts = all_drafts.filter(rfc_number=document_name_to_import[3:])
771779
else:
772780
all_drafts = all_drafts.filter(filename=document_name_to_import)
773-
#all_drafts = all_drafts[all_drafts.count() - 1000:]
774-
#all_drafts = all_drafts.none()
775781

776-
old_internetdraft_content_type_id = ContentType.objects.using("legacy").get(app_label="idtracker", model="internetdraft").pk
777782

778783
for index, o in enumerate(all_drafts.iterator()):
779784
print "importing", o.id_document_tag, o.filename, index, "ballot %s" % o.idinternal.ballot_id if o.idinternal and o.idinternal.ballot_id else ""

redesign/importing/import-meetings.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
from ietf.name.models import *
2525
from ietf.name.utils import name
2626

27+
import_meetings_from = None
28+
if len(sys.argv) > 1:
29+
import_meetings_from = datetime.datetime.strptime(sys.argv[1], "%Y-%m-%d")
30+
31+
2732
dont_save_queries()
2833

2934
# imports Meeting, MeetingVenue, MeetingRoom, NonSession,
@@ -294,7 +299,11 @@ def import_material_kind(kind, doctype):
294299

295300
obviously_bogus_date = datetime.date(1970, 1, 1)
296301

297-
for o in WgMeetingSession.objects.all().order_by("pk").iterator():
302+
all_sessions = WgMeetingSession.objects.all().order_by("pk")
303+
if import_meetings_from:
304+
all_sessions = all_sessions.filter(last_modified_date__gte=import_meetings_from)
305+
306+
for o in all_sessions.iterator():
298307
# num_session is unfortunately not quite reliable, seems to be
299308
# right for 1 or 2 but not 3 and it's sometimes null
300309
sessions = o.num_session or 1

redesign/importing/import-persons.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
# should probably import
2929
# PersonOrOrgInfo/PostalAddress/EmailAddress/PhoneNumber fully
3030

31+
import_docs_from = None
32+
if len(sys.argv) > 1:
33+
import_docs_from = datetime.datetime.strptime(sys.argv[1], "%Y-%m-%d")
34+
35+
3136
# make sure special system user/email is created
3237
print "creating (System) person and email"
3338
try:
@@ -174,7 +179,11 @@
174179
email = get_or_create_email(o, create_fake=True)
175180

176181
# IDAuthor persons
177-
for o in IDAuthor.objects.all().order_by('id').select_related('person').iterator():
182+
all_authors = IDAuthor.objects.all().order_by('id').select_related('person')
183+
if import_docs_from:
184+
all_authors = all_authors.filter(document__last_modified_date__gte=import_docs_from)
185+
186+
for o in all_authors.iterator():
178187
print "importing IDAuthor", o.id, o.person_id, o.person.first_name.encode('utf-8'), o.person.last_name.encode('utf-8')
179188
email = get_or_create_email(o, create_fake=True)
180189

0 commit comments

Comments
 (0)