Skip to content

Commit ed4a389

Browse files
committed
Add augment_with_start_time where start time is currently defined as
time of first revision - Legacy-Id: 3958
1 parent 0107f67 commit ed4a389

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

ietf/doc/utils.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,34 @@ def get_rfc_number(doc):
5656
qs = doc.docalias_set.filter(name__startswith='rfc')
5757
return qs[0].name[3:] if qs else None
5858

59+
def augment_with_start_time(docs):
60+
"""Add a started_time attribute to each document with the time of
61+
the first revision."""
62+
docs = list(docs)
63+
64+
docs_dict = {}
65+
for d in docs:
66+
docs_dict[d.pk] = d
67+
d.start_time = None
68+
69+
seen = set()
70+
71+
for e in DocEvent.objects.filter(type="new_revision", doc__in=docs).order_by('time'):
72+
if e.doc_id in seen:
73+
continue
74+
75+
print e.time, e.doc_id
76+
77+
docs_dict[e.doc_id].start_time = e.time
78+
seen.add(e.doc_id)
79+
80+
return docs
81+
5982
def augment_with_telechat_date(docs):
6083
"""Add a telechat_date attribute to each document with the
6184
scheduled telechat or None if it's not scheduled."""
85+
docs = list(docs)
86+
6287
docs_dict = {}
6388
for d in docs:
6489
docs_dict[d.pk] = d

0 commit comments

Comments
 (0)