Repository: chaoss/augur

Issue:
Pull Request Worker Error 
**Describe the bug:**
The pull request worker is not handling null users. I am not sure if we have unfinished work linking the worker to the contributor model, or if there is a different type of issue. It seems that the worker does not finish a repository once it runs into this error, so if the error occurs in a corpora, the pull requests are not fully populated for that repository. 
```INFO:[PullRequestWorker]: Querying PR Meta
INFO:[PullRequestWorker]: [Filtering] Page recieved has 1 tuples, while filtering duplicates this was reduced to 1 tuples.
INFO:[PullRequestWorker]: [Filtering] Page recieved has 1 tuples, while filtering duplicates this was reduced to 1 tuples.
ERROR:[PullRequestWorker]: Worker ran into an error for task {'task': {'job_type': 'MAINTAIN', 'models': ['pull_requests'], 'display_name': 'pull_requests model for git url: https://github.com/lodash/lodash.git', 'given': {'git_url': 'https://github.com/lodash/lodash.git'}}, 'repo_id': 25204}
Traceback (most recent call last):
  File "/home/sean/census/lib/python3.7/site-packages/pull_request_worker-0.1.0-py3.7.egg/pull_request_worker/worker.py", line 297, in collect
    self.query_pr({'git_url': git_url, 'repo_id': repo_id})
  File "/home/sean/census/lib/python3.7/site-packages/pull_request_worker-0.1.0-py3.7.egg/pull_request_worker/worker.py", line 441, in query_pr
    self.query_pr_meta(pr_dict['head'], pr_dict['base'], self.pr_id_inc)
  File "/home/sean/census/lib/python3.7/site-packages/pull_request_worker-0.1.0-py3.7.egg/pull_request_worker/worker.py", line 651, in query_pr_meta
    if 'login' in new_head[0]['user']:
TypeError: argument of type 'NoneType' is not iterable
ERROR:[PullRequestWorker]: Task failed
ERROR:[PullRequestWorker]: Informing broker about Task Failure
INFO:[PullRequestWorker]: This task inserted 3662 tuples

```
**To Reproduce:**
Steps to reproduce the behavior:
Run the pull request worker. 

**Expected behavior:**
No Errors

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
 - OS: Ubuntu




Discussion:
@parthsharma2 : Wonder if you can take a look at this; I believe its on the server you have access to where I am finding this error. I will send you some of the log. 

Resolving patch:
diff --git a/workers/pull_request_worker/pull_request_worker/worker.py b/workers/pull_request_worker/pull_request_worker/worker.py
--- a/workers/pull_request_worker/pull_request_worker/worker.py
+++ b/workers/pull_request_worker/pull_request_worker/worker.py
@@ -648,7 +648,7 @@ def query_pr_meta(self, head, base,  pr_id):
         new_base = self.check_duplicates([base], meta_table_values, pseudo_key_gh)
 
         if new_head:
-            if 'login' in new_head[0]['user']:
+            if new_head[0]['user'] and 'login' in new_head[0]['user']:
                 cntrb_id = self.find_id_from_login(new_head[0]['user']['login'])
             else:
                 cntrb_id = 1
@@ -675,7 +675,7 @@ def query_pr_meta(self, head, base,  pr_id):
             logger.info('No new PR Head data to add')
 
         if new_base:
-            if 'login' in new_base[0]['user']:
+            if new_base[0]['user'] and 'login' in new_base[0]['user']:
                 cntrb_id = self.find_id_from_login(new_base[0]['user']['login'])
             else:
                 cntrb_id = 1


Test patch: