(self)
| 120 | self._slots = [_MetricSlot(spec, i) for i, spec in enumerate(specs)] |
| 121 | |
| 122 | def build_query(self) -> str: |
| 123 | if not self._slots: |
| 124 | return _EXPOSURES_COUNT_ONLY_QUERY |
| 125 | |
| 126 | unit_selects = ",\n ".join(s.unit_select() for s in self._slots) |
| 127 | outer_selects = ",\n ".join(s.outer_select() for s in self._slots) |
| 128 | |
| 129 | return ( |
| 130 | _EXPOSURES_CTE |
| 131 | + f""", |
| 132 | unit_values AS ( |
| 133 | SELECT |
| 134 | e.variant AS variant, |
| 135 | {unit_selects} |
| 136 | FROM exposures AS e |
| 137 | {_METRIC_JOIN} |
| 138 | WHERE e.quarantined = 0 |
| 139 | GROUP BY e.identifier, e.variant |
| 140 | ) |
| 141 | SELECT variant, count() AS n, |
| 142 | {outer_selects} |
| 143 | FROM unit_values |
| 144 | GROUP BY variant""" |
| 145 | ) |
| 146 | |
| 147 | def add_metric_params(self, params: dict[str, object]) -> None: |
| 148 | """Add per-metric query parameters into an existing params dict.""" |
no test coverage detected