pgadmin4/web/pgadmin/browser/server_groups/servers/pgagent/utils.py
Akshay Joshi ab87035658 pgAgent fixes:
"malformed array literal error when updating pgagent job". Fixes #4428
"Error when updating connection string in pgagent Jobs.". Fixes #4448
When user create a schedule using Create->Schedule dialog browser tree is not showing newly created node.
Properties tab showing same properties for all the created schedule.
Added validation in "pga_jobstep.js", throws error on browser when we modify step from the pgagent dialog and select the same node.
2019-07-15 15:54:57 +01:00

47 lines
1.5 KiB
Python

##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2019, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
"""pgagent helper utilities"""
def format_boolean_array(value):
"""
Converts to proper array data for sql
Args:
value: data to be converted
Returns:
Converted data
"""
if not isinstance(value, list):
return value.replace("[", "{").replace("]", "}")
return value
def format_schedule_data(data):
"""
This function is used to format the schedule data. If data is not an
instance of list then format
:param data:
:return:
"""
if 'jscminutes' in data and data['jscminutes'] is not None:
data['jscminutes'] = format_boolean_array(data['jscminutes'])
if 'jschours' in data and data['jschours'] is not None:
data['jschours'] = format_boolean_array(data['jschours'])
if 'jscweekdays' in data and data['jscweekdays'] is not None:
data['jscweekdays'] = format_boolean_array(data['jscweekdays'])
if 'jscmonthdays' in data and data['jscmonthdays'] is not None:
data['jscmonthdays'] = format_boolean_array(data['jscmonthdays'])
if 'jscmonths' in data and data['jscmonths'] is not None:
data['jscmonths'] = format_boolean_array(data['jscmonths'])
return data