feat: unify scope settings and catalog table interactions
Deploy production / deploy (push) Successful in 54s
Deploy production / deploy (push) Successful in 54s
This commit is contained in:
@@ -30,7 +30,7 @@ def setting_rows(data):
|
||||
try:
|
||||
children = data["actions"]["POST"]["settings"]["children"]
|
||||
|
||||
def choices(key, instrument=None, region=None):
|
||||
def choices(key, instrument=None, region=None, delay=None, universe=None):
|
||||
value = children[key]["choices"]
|
||||
if isinstance(value, dict) and "instrumentType" in value:
|
||||
value = value["instrumentType"][instrument]
|
||||
@@ -38,6 +38,14 @@ def setting_rows(data):
|
||||
value = value[instrument]
|
||||
if isinstance(value, dict) and "region" in value:
|
||||
value = value["region"][region]
|
||||
for dimension, selected in (("delay", delay), ("universe", universe)):
|
||||
if isinstance(value, dict) and dimension in value:
|
||||
branches = value[dimension]
|
||||
if not isinstance(branches, dict):
|
||||
raise ValueError()
|
||||
value = branches.get(str(selected), branches.get(selected))
|
||||
if not isinstance(value, list):
|
||||
raise ValueError()
|
||||
return [item["value"] for item in value]
|
||||
|
||||
rows = []
|
||||
@@ -48,12 +56,29 @@ def setting_rows(data):
|
||||
for delay in choices("delay", instrument, region):
|
||||
if type(delay) is not int or delay not in (0, 1):
|
||||
continue
|
||||
for universe in choices("universe", instrument, region):
|
||||
for universe in choices("universe", instrument, region, delay):
|
||||
neutralizations = (
|
||||
choices("neutralization", instrument, region)
|
||||
choices("neutralization", instrument, region, delay, universe)
|
||||
if "neutralization" in children
|
||||
else []
|
||||
)
|
||||
fields = {}
|
||||
for key in (
|
||||
"decay", "truncation", "pasteurization", "unitHandling",
|
||||
"nanHandling", "language", "visualization", "maxTrade", "maxPosition",
|
||||
):
|
||||
definition = children.get(key)
|
||||
if not isinstance(definition, dict):
|
||||
continue
|
||||
field = {}
|
||||
if "choices" in definition:
|
||||
field["choices"] = choices(key, instrument, region, delay, universe)
|
||||
if any(type(v) not in (str, int, float, bool) for v in field["choices"]):
|
||||
raise ValueError()
|
||||
for source, target in (("min_value", "minimum"), ("max_value", "maximum")):
|
||||
if type(definition.get(source)) in (int, float):
|
||||
field[target] = definition[source]
|
||||
fields[key] = field
|
||||
rows.append(
|
||||
{
|
||||
"instrument_type": instrument,
|
||||
@@ -61,6 +86,7 @@ def setting_rows(data):
|
||||
"universe": universe,
|
||||
"delay": delay,
|
||||
"neutralizations": neutralizations,
|
||||
"fields": fields,
|
||||
}
|
||||
)
|
||||
if not rows:
|
||||
|
||||
Reference in New Issue
Block a user