Added afe_job_id column to the jobs table in TKO. Changed link in AFE
View Job tab to use afe_job_id instead of job_tag.

Signed-off-by: James Ren <jamesren@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@3665 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/tko/db.py b/tko/db.py
index ec83355..4b3f82a 100644
--- a/tko/db.py
+++ b/tko/db.py
@@ -318,13 +318,20 @@
         else:
             self.update_machine_information(job, commit=commit)
 
+        afe_job_id = None
+        pattern = re.compile('^([0-9]+)-.+/.+$')
+        match = pattern.match(tag)
+        if match:
+            afe_job_id = match.group(1)
+
         self.insert('jobs', {'tag':tag,
                              'label': job.label,
                              'username': job.user,
                              'machine_idx': job.machine_idx,
                              'queued_time': job.queued_time,
                              'started_time': job.started_time,
-                             'finished_time': job.finished_time},
+                             'finished_time': job.finished_time,
+                             'afe_job_id': afe_job_id},
                              commit=commit)
         job.index = self.get_last_autonumber_value()
         for test in job.tests: