Cleanup the amount of conditionals and temp variables in patch
This commit is contained in:
parent
9113a2cbbe
commit
6f3492343c
|
@ -32,3 +32,6 @@ class StreamDefinitionsV2API(object):
|
||||||
|
|
||||||
def on_delete(self, req, res, stream_id):
|
def on_delete(self, req, res, stream_id):
|
||||||
res.status = '501 Not Implemented'
|
res.status = '501 Not Implemented'
|
||||||
|
|
||||||
|
def on_patch(self, req, res, stream_id):
|
||||||
|
res.status = '501 Not Implemented'
|
||||||
|
|
|
@ -242,52 +242,40 @@ class StreamsRepository(mysql_repository.MySQLRepository,
|
||||||
where tenant_id = %s and id = %s"""
|
where tenant_id = %s and id = %s"""
|
||||||
|
|
||||||
if name is None:
|
if name is None:
|
||||||
new_name = original_definition['name']
|
name = original_definition['name']
|
||||||
else:
|
|
||||||
new_name = name.encode('utf8')
|
|
||||||
|
|
||||||
if description is None:
|
if description is None:
|
||||||
new_description = original_definition['description']
|
description = original_definition['description']
|
||||||
else:
|
|
||||||
new_description = description.encode('utf8')
|
|
||||||
|
|
||||||
if select is None:
|
if select is None:
|
||||||
new_select = original_definition['select_by']
|
select = original_definition['select_by']
|
||||||
else:
|
|
||||||
new_select = json.dumps(select).encode('utf8')
|
|
||||||
|
|
||||||
if new_select != original_definition['select_by']:
|
if select != original_definition['select_by']:
|
||||||
msg = "select_by must not change".encode('utf8')
|
msg = "select_by must not change".encode('utf8')
|
||||||
raise exceptions.InvalidUpdateException(msg)
|
raise exceptions.InvalidUpdateException(msg)
|
||||||
|
|
||||||
if group_by is None:
|
if group_by is None:
|
||||||
new_group_by = original_definition['group_by']
|
group_by = original_definition['group_by']
|
||||||
else:
|
|
||||||
new_group_by = json.dumps(group_by).encode('utf8')
|
|
||||||
|
|
||||||
if new_group_by != original_definition['group_by']:
|
if group_by != original_definition['group_by']:
|
||||||
msg = "group_by must not change".encode('utf8')
|
msg = "group_by must not change".encode('utf8')
|
||||||
raise exceptions.InvalidUpdateException(msg)
|
raise exceptions.InvalidUpdateException(msg)
|
||||||
|
|
||||||
if fire_criteria is None:
|
if fire_criteria is None:
|
||||||
new_fire_criteria = original_definition['fire_criteria']
|
fire_criteria = original_definition['fire_criteria']
|
||||||
else:
|
|
||||||
new_fire_criteria = json.dumps(fire_criteria).encode('utf8')
|
|
||||||
|
|
||||||
if expiration is None:
|
if expiration is None:
|
||||||
new_expiration = original_definition['expiration']
|
expiration = original_definition['expiration']
|
||||||
else:
|
|
||||||
new_expiration = expiration
|
|
||||||
|
|
||||||
now = timeutils.utcnow()
|
now = timeutils.utcnow()
|
||||||
|
|
||||||
update_parms = [
|
update_parms = [
|
||||||
new_name,
|
name,
|
||||||
new_description,
|
description,
|
||||||
new_select,
|
select,
|
||||||
new_group_by,
|
group_by,
|
||||||
new_fire_criteria,
|
fire_criteria,
|
||||||
new_expiration,
|
expiration,
|
||||||
now,
|
now,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
stream_definition_id]
|
stream_definition_id]
|
||||||
|
|
|
@ -248,9 +248,10 @@ class StreamDefinitions(stream_definitions_api_v2.StreamDefinitionsV2API):
|
||||||
stream_definition_id,
|
stream_definition_id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
select,
|
None if select is None else json.dumps(select),
|
||||||
group_by,
|
None if group_by is None else json.dumps(group_by),
|
||||||
fire_criteria,
|
None if fire_criteria is None else json.dumps(
|
||||||
|
fire_criteria),
|
||||||
expiration,
|
expiration,
|
||||||
fire_actions,
|
fire_actions,
|
||||||
expire_actions))
|
expire_actions))
|
||||||
|
|
Loading…
Reference in New Issue