Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for issue #301 with race in cohort #303

Merged
merged 6 commits into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions icees_api/features/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,19 +546,23 @@ def create_cohort_view(conn, table_name, cohort_features):
"feature_name": key,
"feature_qualifier": {
"operator": value["operator"],
"value": value["value"],
},
# value only has two possible keys, value key for one value, and values key for a list of values
# format value["values"] list into ("value1", "value2", ...,) for SQL IN operator query
"value": value.get("value") if value.get("value") is not None
else '("{}")'.format('\", \"'.join(value["values"]))
}
}
for key, value in cohort_features.items()
]

if cohort_features:
# only add quotation marks to value if operator is =
condition_str = " AND ".join(
"\"{}\" {} \"{}\"".format(
feature["feature_name"],
feature["feature_qualifier"]["operator"],
feature["feature_qualifier"]["value"],
)
for feature in cohort_features)
("\"{}\" {} \"{}\"" if feature["feature_qualifier"]["operator"] == '=' else "\"{}\" {} {}").format(
feature["feature_name"],
feature["feature_qualifier"]["operator"],
feature["feature_qualifier"]["value"]
) for feature in cohort_features)

view_query = (
"CREATE VIEW tmp AS "
Expand Down
Loading