diff --git a/src/covsonar/dbm.py b/src/covsonar/dbm.py index e47c07c..5469c5e 100755 --- a/src/covsonar/dbm.py +++ b/src/covsonar/dbm.py @@ -2016,7 +2016,6 @@ def build_string_condition( ) # Add the value to the corresponding operator set - val = sonarDbManager.custom_strip(val, "%") data[operator].append(val) # Assemble query conditions and values @@ -2390,9 +2389,9 @@ def create_sample_property_case( pid += 1 case, val = self.build_sample_property_condition(pname.lstrip("."), *vals) property_cases.append( - f"CASE WHEN {' AND '.join(case)} THEN 1 ELSE 0 END AS property_{pid}" + f"SUM(CASE WHEN {' AND '.join(case)} THEN 1 ELSE 0 END) AS property_{pid}" ) - property_conditions.append(f"property_{pid} = 1") + property_conditions.append(f"property_{pid} >= 1") property_vals.extend(val) return property_cases, property_conditions, property_vals @@ -2442,7 +2441,7 @@ def create_profile_cases( if match: case, val = processing_funcs[mutation_type](match) cases.append( - f"CASE WHEN {' AND '.join(case)} THEN 1 ELSE 0 END AS mutation_{ids[mutation]}" + f"SUM(CASE WHEN {' AND '.join(case)} THEN 1 ELSE 0 END) AS mutation_{ids[mutation]}" ) vals.extend(val) break @@ -2450,7 +2449,10 @@ def create_profile_cases( LOGGER.error(f"Invalid mutation notation '{mutation}'.") sys.exit(1) - where_conditions.append(f"mutation_{ids[mutation]} = {count}") + if count == 0: + where_conditions.append(f"mutation_{ids[mutation]} = {count}") + else: + where_conditions.append(f"mutation_{ids[mutation]} >= {count}") if len(where_conditions) == 1: wheres.extend(where_conditions) @@ -2551,7 +2553,7 @@ def create_sample_selection_sql( if conditions: conditions = " AND ".join(conditions) - sql += f" WHERE {conditions}" + sql += f" GROUP BY s.id HAVING {conditions}" sql += ") AS sub"