diff --git a/drafttopic/utilities/fetch_page_wikiprojects.py b/drafttopic/utilities/fetch_page_wikiprojects.py index 5abd6cf..5ac306a 100644 --- a/drafttopic/utilities/fetch_page_wikiprojects.py +++ b/drafttopic/utilities/fetch_page_wikiprojects.py @@ -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']) diff --git a/drafttopic/utilities/tests/test_fetch_page_wikiprojects.py b/drafttopic/utilities/tests/test_fetch_page_wikiprojects.py index c6e3b9f..1acb953 100644 --- a/drafttopic/utilities/tests/test_fetch_page_wikiprojects.py +++ b/drafttopic/utilities/tests/test_fetch_page_wikiprojects.py @@ -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': []} ]}}]