MCPcopy Create free account
hub / github.com/Flagsmith/flagsmith / build_query

Method build_query

api/experimentation/results_query.py:122–145  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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""",
132unit_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)
141SELECT variant, count() AS n,
142 {outer_selects}
143FROM unit_values
144GROUP 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."""

Callers 1

get_metric_variant_statsFunction · 0.95

Calls 2

unit_selectMethod · 0.80
outer_selectMethod · 0.80

Tested by

no test coverage detected