Repository: chaoss/augur

Issue:
repo_info worker: dev/test branch
Please help us help you by filling out the following sections as thoroughly as you can.

**Description:**
Looks like the new Fork information collection has some kind of mismatch between the method and parameters passed: 

```
INFO:root:Worker ran into an error for task: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}}

INFO:root:Printing traceback...

INFO:root:Traceback (most recent call last):
  File "/mnt/md0/github/augur-census/workers/worker_base.py", line 189, in collect
    model_method(message, repo_id)
  File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 149, in repo_info_model
    forked = self.is_forked(owner, repo)
  File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 232, in is_forked
    data = self.get_repo_data(self, url, r)
TypeError: get_repo_data() takes 3 positional arguments but 4 were given

INFO:root:This task inserted 0 tuples before failure.

INFO:root:Notifying broker and logging task failure in database...

INFO:werkzeug:127.0.0.1 - - [31/May/2020 18:48:58] "GET /AUGWOP/heartbeat HTTP/1.1" 200 -
INFO:root:Recorded job error in the history table for: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}, 'worker_id': 'com.augurlabs.core.repo_info_worker.50700'}

INFO:root:Updated job process for model: repo_info
```

If the log does not provide enough info, let me know 


Discussion:

Resolving patch:
diff --git a/workers/repo_info_worker/repo_info_worker.py b/workers/repo_info_worker/repo_info_worker.py
--- a/workers/repo_info_worker/repo_info_worker.py
+++ b/workers/repo_info_worker/repo_info_worker.py
@@ -23,7 +23,7 @@ def __init__(self, config={}):
         models = ['repo_info']
 
         # Define the tables needed to insert, update, or delete on
-        data_tables = ['repo_info']
+        data_tables = ['repo_info', 'repo']
         operations_tables = ['worker_history', 'worker_job']
 
         # Run the general worker initialization
@@ -144,14 +144,6 @@ def repo_info_model(self, task, repo_id):
 
         # Get committers count info that requires seperate endpoint
         committers_count = self.query_committers_count(owner, repo)
-        # Note that the addition of information about where a repository may be forked from, and whether a repository is archived, updates the `repo` table, not the `repo_info` table.
-        forked = self.is_forked(owner, repo)
-        archived = self.is_archived(owner, repo)
-        if archived is not False:
-            archived_date_collected = archived
-            archived = True
-        else:
-            archived_date_collected = None
 
         # Put all data together in format of the table
         self.logger.info(f'Inserting repo info for repo with id:{repo_id}, owner:{owner}, name:{repo}\n')
@@ -189,15 +181,30 @@ def repo_info_model(self, task, repo_id):
             'tool_source': self.tool_source,
             'tool_version': self.tool_version,
             'data_source': self.data_source
-            # 'forked_from': forked,
-            # 'repo_archived': archived,
-            # 'repo_archived_date_collected': archived_date_collected
         }
 
         result = self.db.execute(self.repo_info_table.insert().values(rep_inf))
         self.logger.info(f"Primary Key inserted into repo_info table: {result.inserted_primary_key}\n")
         self.results_counter += 1
 
+        # Note that the addition of information about where a repository may be forked from, and whether a repository is archived, updates the `repo` table, not the `repo_info` table.
+        forked = self.is_forked(owner, repo)
+        archived = self.is_archived(owner, repo)
+        archived_date_collected = None
+        if archived is not False:
+            archived_date_collected = archived
+            archived = 1
+        else:
+            archived = 0
+
+        rep_additional_data = {
+            'forked_from': forked,
+            'repo_archived': archived,
+            'repo_archived_date_collected': archived_date_collected
+        }
+        result = self.db.execute(self.repo_table.update().where(repo_table.c.repo_id==repo_id).values(rep_additional_data))
+        self.logger.info(f"Primary Key inserted into repo table: {result.inserted_primary_key}\n")
+
         self.logger.info(f"Inserted info for {owner}/{repo}\n")
 
         # Register this task as completed
@@ -219,12 +226,12 @@ def query_committers_count(self, owner, repo):
                 else:
                     url = r.links['next']['url']
         except Exception:
-            logging.exception('An error occured while querying contributor count\n')
+            self.logger.exception('An error occured while querying contributor count\n')
 
         return committers
 
     def is_forked(self, owner, repo): #/repos/:owner/:repo parent
-        logging.info('Querying parent info to verify if the repo is forked\n')
+        self.logger.info('Querying parent info to verify if the repo is forked\n')
         url = f'https://api.github.com/repos/{owner}/{repo}'
 
         r = requests.get(url, headers=self.headers)
@@ -240,7 +247,7 @@ def is_forked(self, owner, repo): #/repos/:owner/:repo parent
         return False
 
     def is_archived(self, owner, repo):
-        logging.info('Querying committers count\n')
+        self.logger.info('Querying committers count\n')
         url = f'https://api.github.com/repos/{owner}/{repo}'
 
         r = requests.get(url, headers=self.headers)
@@ -265,16 +272,16 @@ def get_repo_data(self, url, response):
             data = json.loads(json.dumps(response.text))
 
         if 'errors' in data:
-            logging.info("Error!: {}".format(data['errors']))
+            self.logger.info("Error!: {}".format(data['errors']))
             if data['errors'][0]['message'] == 'API rate limit exceeded':
                 self.update_gh_rate_limit(response)
 
         if 'id' in data:
             success = True
         else:
-            logging.info("Request returned a non-data dict: {}\n".format(data))
+            self.logger.info("Request returned a non-data dict: {}\n".format(data))
             if data['message'] == 'Not Found':
-                logging.info("Github repo was not found or does not exist for endpoint: {}\n".format(url))
+                self.logger.info("Github repo was not found or does not exist for endpoint: {}\n".format(url))
             if data['message'] == 'You have triggered an abuse detection mechanism. Please wait a few minutes before you try again.':
                 self.update_gh_rate_limit(r, temporarily_disable=True)
             if data['message'] == 'Bad credentials':


Test patch: