Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions drafttopic/utilities/fetch_page_wikiprojects.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,17 @@ def _fetch_wikiprojects_info(observations):
if pageid not in rev_doc_map:
rev_doc_map[pageid] = \
{'talk_page_id': pageid,
'rev_id': page_doc['lastrevid'], 'templates': [],
'talk_page_title': page_doc['title']}
'rev_id': page_doc.get('lastrevid', -1),
'templates': [],
'talk_page_title': page_doc.get('title', '')}
# some templates for this pageid were processed in previous
# batches, update the list with new one's
if 'lastrevid' in page_doc:
rev_doc_map[pageid]['rev_id'] = \
page_doc['lastrevid']
if 'title' in page_doc:
rev_doc_map[pageid]['talk_page_title'] = \
page_doc['title']
if 'templates' in page_doc:
templates = extract_wikiproject_templates(
page_doc['templates'])
Expand Down
4 changes: 2 additions & 2 deletions drafttopic/utilities/tests/test_fetch_page_wikiprojects.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ def test_extract_wikiproject_templates():


mwapi_responses = [{'query': {'pages': [
{'pageid': 123, 'templates': [], 'lastrevid': 121, 'title': 'Page A'},
{'pageid': 123, 'templates': [], 'title': 'Page A'},
{'pageid': 456, 'templates': [
{'title': 'Template:WikiProject abc'}, {'title': 'xyz'}],
'lastrevid': 111, 'title': 'Page B'}
]}}, {'query': {'pages': [
{'pageid': 123, 'templates': [
{'pageid': 123, 'lastrevid': 121, 'templates': [
{'title': 'Template:WikiProject xyz'}, {'title': 'abc'}]},
{'pageid': 456, 'templates': []}
]}}]
Expand Down