in generator/explores/client_counts_explore.py [0:0]
def _to_lookml(self, v1_name: Optional[str]) -> List[Dict[str, Any]]:
"""Generate LookML to represent this explore."""
queries = []
if time_partitioning_group := self.get_view_time_partitioning_group(
self.views["extended_view"]
):
date_dimension = f"{time_partitioning_group}_date"
queries.append(
{
"description": "Client Counts of weekly cohorts over the past N days.",
"dimensions": ["days_since_first_seen", "first_seen_week"],
"measures": ["client_count"],
"pivots": ["first_seen_week"],
"filters": [
{date_dimension: "8 weeks"},
{"first_seen_date": "8 weeks"},
{"have_completed_period": "yes"},
],
"sorts": [{"days_since_first_seen": "asc"}],
"name": "cohort_analysis",
}
)
if self.has_view_dimension(self.views["extended_view"], "app_build"):
queries.append(
{
"description": "Number of clients per build.",
"dimensions": [date_dimension, "app_build"],
"measures": ["client_count"],
"pivots": ["app_build"],
"sorts": [{date_dimension: "asc"}],
"name": "build_breakdown",
}
)
explore_lookml = {
"name": self.name,
"view_name": self.views["base_view"],
"description": "Client counts across dimensions and cohorts.",
"always_filter": {
"filters": self.get_required_filters("extended_view"),
},
"queries": queries,
"joins": self.get_unnested_fields_joins_lookml(),
}
if datagroup := self.get_datagroup():
explore_lookml["persist_with"] = datagroup
return [explore_lookml]