autotest: Stop returning duplicate data from tko/db.insert_job

BUG=chromium:833988
TEST=None

Change-Id: Iab07cb3cd1b5a42c316af8ea1e526e5dce232c62
Reviewed-on: https://chromium-review.googlesource.com/1018582
Commit-Ready: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
diff --git a/tko/db.py b/tko/db.py
index b682abe..d84922b 100644
--- a/tko/db.py
+++ b/tko/db.py
@@ -440,8 +440,6 @@
         @param job: The job object.
         @param parent_job_id: The parent job id.
         @param commit: If commit the transaction .
-
-        @return The dict of data inserted into the tko_jobs table.
         """
         afe_job_id = utils.get_afe_job_id(tag)
 
@@ -469,8 +467,6 @@
         else:
             self.insert('tko_jobs', data, commit=commit)
             job.index = self.get_last_autonumber_value()
-        data['job_idx'] = job.index
-        return data
 
 
     def update_job_keyvals(self, job, commit=None):
diff --git a/tko/parse.py b/tko/parse.py
index 993d149..ecf0f9f 100755
--- a/tko/parse.py
+++ b/tko/parse.py
@@ -445,7 +445,7 @@
 
             # write the job into the database.
             db.insert_or_update_machine(job)
-            job_data = db.insert_job(
+            db.insert_job(
                 jobname, job,
                 parent_job_id=job_keyval.get(constants.PARENT_JOB_ID, None))
             db.update_job_keyvals(job)
@@ -454,14 +454,13 @@
 
             # Verify the job data is written to the database.
             if job.tests:
-                tests_in_db = db.find_tests(job_data['job_idx'])
+                tests_in_db = db.find_tests(job.index)
                 tests_in_db_count = len(tests_in_db) if tests_in_db else 0
                 if tests_in_db_count != len(job.tests):
                     tko_utils.dprint(
                             'Failed to find enough tests for job_idx: %d. The '
                             'job should have %d tests, only found %d tests.' %
-                            (job_data['job_idx'], len(job.tests),
-                             tests_in_db_count))
+                            (job.index, len(job.tests), tests_in_db_count))
                     metrics.Counter(
                             'chromeos/autotest/result/db_save_failure',
                             description='The number of times parse failed to '
@@ -512,12 +511,12 @@
         datastore_parent_key = job_keyval.get('datastore_parent_key', None)
         provision_job_id = job_keyval.get('provision_job_id', None)
         if (suite_report and jobname.endswith('/hostless')
-            and job_data['suite'] and datastore_parent_key):
+            and job.suite and datastore_parent_key):
             tko_utils.dprint('Start dumping suite timing report...')
             timing_log = os.path.join(path, 'suite_timing.log')
             dump_cmd = ("%s/site_utils/dump_suite_report.py %s "
                         "--output='%s' --debug" %
-                        (common.autotest_dir, job_data['afe_job_id'],
+                        (common.autotest_dir, job.afe_job_id,
                          timing_log))
 
             if provision_job_id is not None: