1
0
mirror of https://github.com/djohnlewis/stackdump synced 2024-12-04 23:17:37 +00:00

Removed more redundant date/time parsing.

This commit is contained in:
Samuel Lai 2013-11-29 15:11:32 +11:00
parent 522e1ff4f2
commit 2583afeb90

View File

@ -265,19 +265,20 @@ class PostContentHandler(xml.sax.ContentHandler):
if 'AcceptedAnswerId' in attrs: if 'AcceptedAnswerId' in attrs:
d['acceptedAnswerId'] = int(attrs.get('AcceptedAnswerId', 0)) d['acceptedAnswerId'] = int(attrs.get('AcceptedAnswerId', 0))
d['creationDate'] = datetime.strptime(attrs.get('CreationDate'), ISO_DATE_FORMAT) # Solr accepts ISO dates, but must be UTC as indicated by trailing Z
d['creationDate'] = attrs.get('CreationDate') + 'Z'
d['score'] = int(attrs.get('Score', 0)) d['score'] = int(attrs.get('Score', 0))
d['body'] = attrs.get('Body', '') d['body'] = attrs.get('Body', '')
d['ownerUserId'] = int(attrs.get('OwnerUserId', 0)) d['ownerUserId'] = int(attrs.get('OwnerUserId', 0))
if 'LastEditorUserId' in attrs: if 'LastEditorUserId' in attrs:
d['lastEditorUserId'] = int(attrs.get('LastEditorUserId', 0)) d['lastEditorUserId'] = int(attrs.get('LastEditorUserId', 0))
if 'LastEditDate' in attrs: if 'LastEditDate' in attrs:
d['lastEditDate'] = datetime.strptime(attrs.get('LastEditDate'), ISO_DATE_FORMAT) d['lastEditDate'] = attrs.get('LastEditDate') + 'Z'
d['lastActivityDate'] = datetime.strptime(attrs.get('LastActivityDate'), ISO_DATE_FORMAT) d['lastActivityDate'] = attrs.get('LastActivityDate') + 'Z'
if 'CommunityOwnedDate' in attrs: if 'CommunityOwnedDate' in attrs:
d['communityOwnedDate'] = datetime.strptime(attrs.get('CommunityOwnedDate'), ISO_DATE_FORMAT) d['communityOwnedDate'] = attrs.get('CommunityOwnedDate') + 'Z'
if 'ClosedDate' in attrs: if 'ClosedDate' in attrs:
d['closedDate'] = datetime.strptime(attrs.get('ClosedDate'), ISO_DATE_FORMAT) d['closedDate'] = attrs.get('ClosedDate') + 'Z'
d['title'] = attrs.get('Title', '') d['title'] = attrs.get('Title', '')
if 'Tags' in attrs: if 'Tags' in attrs:
d['tags'] = attrs.get('Tags', '') d['tags'] = attrs.get('Tags', '')