Merge branch 'refdata-derived-models' into jobs-derived-models

This commit is contained in:
Cameron Dawson 2013-04-16 08:40:47 -07:00
Родитель 732f4c9bd2 4f6921caa1
Коммит 6624f68d09
2 изменённых файлов: 81 добавлений и 12 удалений

Просмотреть файл

@ -35,16 +35,52 @@ class RefDataManager(TreeherderModelBase):
platform,
architecture)
def get_job_type_id(self, name):
def get_job_group_id(self, name):
id_iter = self.sources["jobs"].dhub.execute(
proc='reference.selects.get_job_type_id',
proc='reference.selects.get_job_group_id',
placeholders=[name],
debug_show=self.DEBUG,
return_type='iter')
return id_iter.get_column_data('id')
def get_or_create_job_group(self, name):
self.sources["jobs"].dhub.execute(
proc='reference.inserts.create_job_group',
placeholders=[
name,
name
],
debug_show=self.DEBUG)
return self.get_job_group_id(name)
def get_job_type_id(self, name, group):
id_iter = self.sources["jobs"].dhub.execute(
proc='reference.selects.get_job_type_id',
placeholders=[name, group],
debug_show=self.DEBUG,
return_type='iter')
return id_iter.get_column_data('id')
def get_or_create_job_type(self, name, group):
self.sources["jobs"].dhub.execute(
proc='reference.inserts.create_job_type',
placeholders=[
name,
group,
name,
group
],
debug_show=self.DEBUG)
return self.get_job_type_id(name)
def get_machine_id(self, name):
id_iter = self.sources["jobs"].dhub.execute(
@ -108,13 +144,12 @@ class RefDataManager(TreeherderModelBase):
return id_iter.get_column_data('id')
def get_or_create_option(self, name, description):
def get_or_create_option(self, name):
self.sources["jobs"].dhub.execute(
proc='reference.inserts.create_option',
placeholders=[
name,
description,
name
],
debug_show=self.DEBUG)
@ -150,8 +185,7 @@ class RefDataManager(TreeherderModelBase):
for option in options:
#create an option if it doesn't exist
option_id = self.get_or_create_option(option,
'description needed')
option_id = self.get_or_create_option(option)
# create an entry in option_collection
self.sources["jobs"].dhub.execute(
@ -176,13 +210,12 @@ class RefDataManager(TreeherderModelBase):
return id_iter.get_column_data('id')
def get_or_create_product(self, name, description):
def get_or_create_product(self, name):
self.sources["jobs"].dhub.execute(
proc='reference.inserts.create_product',
placeholders=[
name,
description,
name
],
debug_show=self.DEBUG)

Просмотреть файл

@ -12,6 +12,30 @@
"host":"master_host"
},
"create_job_group":{
"sql":"INSERT INTO `job_group` (`symbol`, `name`, `description`, `active_status`)
SELECT 'fill me', ?, 'fill me', 'active'
FROM DUAL
WHERE NOT EXISTS (
SELECT `name`
FROM `job_group`
WHERE `name` = ?
)",
"host":"master_host"
},
"create_job_type":{
"sql":"INSERT INTO `job_type` (`job_group_id`, `symbol`, `name`, `description`, `active_status`)
SELECT ?, 'fill me', ?, 'fill me', 'active'
FROM DUAL
WHERE NOT EXISTS (
SELECT `name`
FROM `job_type`
WHERE `job_group_id` = ? and `name` = ?
)",
"host":"master_host"
},
"create_machine" : {
"sql": "INSERT INTO `machine` (`name`, `first_timestamp`, `last_timestamp`, `active_status`)
SELECT ?, ?, ?, 'active'
@ -39,7 +63,7 @@
"create_option":{
"sql":"INSERT INTO `option` (`name`, `description`, `active_status`)
SELECT ?, ?, ?, 'active'
SELECT ?, 'fill me', ?, 'active'
FROM DUAL
WHERE NOT EXISTS (
SELECT `name`
@ -63,7 +87,7 @@
"create_product":{
"sql": "INSERT INTO `product` (`name`, `description`, `active_status`)
SELECT ?, ?, 'active'
SELECT ?, 'fill me', 'active'
FROM DUAL
WHERE NOT EXISTS (
SELECT `name`
@ -96,14 +120,26 @@
AND `active_status` = 'active'",
"host":"read_host"
},
"get_job_type_id":{
"get_job_group_id":{
"sql": "SELECT `id`
FROM `job_type`
FROM `job_group`
WHERE
`name` = ?
AND `active_status` = 'active'",
"host":"read_host"
},
"get_job_type_id":{
"sql": "SELECT jt.`id`
FROM `job_type` jt
INNER JOIN `job_group` jg
ON jg.id = jt.job_group_id
WHERE
jt.`name` = ?
AND jg.`name` = ?
AND jt.`active_status` = 'active'
AND jg.`active_status` = 'active'",
"host":"read_host"
},
"get_machine_id":{
"sql": "SELECT `id`
FROM `machine`