add ai-user filter combinations
This commit is contained in:
42
plots.py
42
plots.py
@@ -136,9 +136,45 @@ class QualtricsPlotsMixin:
|
||||
if master_list and set(value) == set(master_list):
|
||||
continue
|
||||
|
||||
# Use original values for display (full list)
|
||||
clean_values = [str(v) for v in value]
|
||||
val_str = ", ".join(clean_values)
|
||||
# Special handling for Ethnicity: detect single-value ethnicity filters
|
||||
# When filtering by one ethnicity (e.g., "White or Caucasian"), multiple options
|
||||
# may be selected (all options containing that value). Display just the common value
|
||||
# only if ALL options containing that value are selected.
|
||||
if display_name.lower() == 'ethnicity' and len(value) > 1 and master_list:
|
||||
# Find common individual ethnicity values across all selected options
|
||||
# Each option may be comma-separated (e.g., "White or Caucasian, Hispanic or Latino")
|
||||
value_sets = [
|
||||
set(v.strip() for v in opt.split(','))
|
||||
for opt in value
|
||||
]
|
||||
# Intersect all sets to find common values
|
||||
common_values = value_sets[0]
|
||||
for vs in value_sets[1:]:
|
||||
common_values = common_values.intersection(vs)
|
||||
|
||||
# If exactly one common value, check if ALL options containing it are selected
|
||||
if len(common_values) == 1:
|
||||
common_val = common_values.pop()
|
||||
# Find all options in master list that contain this common value
|
||||
all_options_with_value = [
|
||||
opt for opt in master_list
|
||||
if common_val in [v.strip() for v in opt.split(',')]
|
||||
]
|
||||
# Only simplify if we selected ALL options containing this value
|
||||
if set(value) == set(all_options_with_value):
|
||||
val_str = common_val
|
||||
else:
|
||||
clean_values = [str(v) for v in value]
|
||||
val_str = ", ".join(clean_values)
|
||||
else:
|
||||
# No single common value - fall back to full list
|
||||
clean_values = [str(v) for v in value]
|
||||
val_str = ", ".join(clean_values)
|
||||
else:
|
||||
# Use original values for display (full list)
|
||||
clean_values = [str(v) for v in value]
|
||||
val_str = ", ".join(clean_values)
|
||||
|
||||
# Use UPPERCASE for category name to distinguish from values
|
||||
parts.append(f"{display_name.upper()}: {val_str}")
|
||||
|
||||
|
||||
@@ -130,6 +130,20 @@ def get_filter_combinations(survey: QualtricsSurvey) -> list[dict]:
|
||||
'filters': {'ai_user': [ai_user]}
|
||||
})
|
||||
|
||||
# AI user daily, more than once daily, en multiple times a week = frequent
|
||||
combinations.append({
|
||||
'name': 'AIUser-Frequent',
|
||||
'filters': {'ai_user': [
|
||||
'Daily', 'More than once daily', 'Multiple times per week'
|
||||
]}
|
||||
})
|
||||
combinations.append({
|
||||
'name': 'AIUser-Infrequent',
|
||||
'filters': {'ai_user': [
|
||||
'Once a month', 'Less than once a month', 'Once a week'
|
||||
]}
|
||||
})
|
||||
|
||||
# Investable Assets - one at a time
|
||||
for investable_assets in survey.options_investable_assets:
|
||||
combinations.append({
|
||||
|
||||
Reference in New Issue
Block a user