diff --git a/treeherder/model/derived/jobs.py b/treeherder/model/derived/jobs.py index e95429f69..e25f4e87d 100644 --- a/treeherder/model/derived/jobs.py +++ b/treeherder/model/derived/jobs.py @@ -171,6 +171,15 @@ class JobsModel(TreeherderModelBase): debug_show=self.DEBUG ) + self.get_jobs_dhub().execute( + proc='jobs.updates.update_last_job_classification', + placeholders=[ + failure_classification_id, + job_id, + ], + debug_show=self.DEBUG + ) + def get_result_set_ids(self, revision_hashes, where_in_list): """Return the a dictionary of revision_hash to id mappings given a list of revision_hashes and a where_in_list. diff --git a/treeherder/model/fixtures/failure_classification.json b/treeherder/model/fixtures/failure_classification.json new file mode 100644 index 000000000..da5cd9cd7 --- /dev/null +++ b/treeherder/model/fixtures/failure_classification.json @@ -0,0 +1,56 @@ +[ + { + "pk": 1, + "model": "model.failureclassification", + "fields": { + "name": "not classified", + "description": "", + "active_status": "active" + } + }, + { + "pk": 2, + "model": "model.failureclassification", + "fields": { + "name": "expected fail", + "description": "", + "active_status": "active" + } + }, + { + "pk": 3, + "model": "model.failureclassification", + "fields": { + "name": "expected fail", + "description": "", + "active_status": "active" + } + }, + { + "pk": 4, + "model": "model.failureclassification", + "fields": { + "name": "intermittent", + "description": "", + "active_status": "active" + } + }, + { + "pk": 5, + "model": "model.failureclassification", + "fields": { + "name": "infra", + "description": "", + "active_status": "active" + } + }, + { + "pk": 6, + "model": "model.failureclassification", + "fields": { + "name": "intermittent needs filing", + "description": "", + "active_status": "active" + } + } +] \ No newline at end of file diff --git a/treeherder/model/management/commands/load_initial_data.py b/treeherder/model/management/commands/load_initial_data.py index 34701f308..8a907db8e 100644 --- a/treeherder/model/management/commands/load_initial_data.py +++ b/treeherder/model/management/commands/load_initial_data.py @@ -9,4 +9,5 @@ class Command(BaseCommand): call_command('loaddata', 'repository_group', 'repository', - 'tasks') + 'tasks', + 'failure_classification') diff --git a/treeherder/model/sql/jobs.json b/treeherder/model/sql/jobs.json index 6d88d1e5f..6c3547fe6 100644 --- a/treeherder/model/sql/jobs.json +++ b/treeherder/model/sql/jobs.json @@ -153,6 +153,13 @@ SET `job_coalesced_to_guid` = ? WHERE `job_guid` = ?", + "host":"master_host" + }, + "update_last_job_classification":{ + "sql":"UPDATE `job` + SET `failure_classification_id` = ? + WHERE `job_id` = ?", + "host":"master_host" } }, diff --git a/treeherder/model/sql/template_schema/project_jobs_1.sql.tmpl b/treeherder/model/sql/template_schema/project_jobs_1.sql.tmpl index 4717346cd..c2669dfcf 100644 --- a/treeherder/model/sql/template_schema/project_jobs_1.sql.tmpl +++ b/treeherder/model/sql/template_schema/project_jobs_1.sql.tmpl @@ -83,6 +83,7 @@ DROP TABLE IF EXISTS `job`; * option_collection_hash - References treeherder_reference_1.option_collection.option_collection_hash * job_type_id - References treeherder_reference_1.job_type.id * product_id - References treeherder_reference_1.product.id + * failure_classification_id - References treeherder_reference_1.failure_classification.id * who - Description of who submitted the job: gaia | scheduler name | username * reason - Reason for the job: push | scheduled | self-serve | manual * result - Job outcome description: success | failure | ... @@ -102,6 +103,7 @@ CREATE TABLE `job` ( `option_collection_hash` varchar(64) COLLATE utf8_bin DEFAULT NULL, `job_type_id` int(10) unsigned NOT NULL, `product_id` int(10) unsigned DEFAULT NULL, + `failure_classification_id` int(10) unsigned DEFAULT 1, `who` varchar(50) COLLATE utf8_bin NOT NULL, `reason` varchar(125) COLLATE utf8_bin NOT NULL, `result` varchar(25) COLLATE utf8_bin DEFAULT NULL, @@ -120,6 +122,7 @@ CREATE TABLE `job` ( KEY `idx_option_collection_hash` (`option_collection_hash`), KEY `idx_job_type_id` (`job_type_id`), KEY `idx_product_id` (`product_id`), + KEY `idx_failure_classification_id` (`failure_classification_id`), KEY `idx_who` (`who`), KEY `idx_reason` (`reason`), KEY `idx_result` (`result`),