Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(retention): fix period in retetion csv title column #19451

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions posthog/api/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ def retention(self, request: request.Request) -> response.Response:
"result": people,
"next": next_url,
"missing_persons": raw_count - len(people),
"filters": filter.to_dict(),
}
)

Expand Down
3 changes: 2 additions & 1 deletion posthog/tasks/exports/csv_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,12 @@ def _convert_response_to_csv_data(data: Any) -> List[Any]:
return csv_rows
elif first_result.get("appearances") and first_result.get("person"):
# RETENTION PERSONS LIKE
period = data["filters"]["period"] or "Day"
csv_rows = []
for item in items:
line = {"person": item["person"]["name"]}
for index, data in enumerate(item["appearances"]):
line[f"Day {index}"] = data
line[f"{period} {index}"] = data

csv_rows.append(line)
return csv_rows
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"csv_rows": [
"person,Day 0,Day 1,Day 2,Day 3,Day 4,Day 5,Day 6,Day 7,Day 8,Day 9,Day 10",
"person,Week 0,Week 1,Week 2,Week 3,Week 4,Week 5,Week 6,Week 7,Week 8,Week 9,Week 10",
"[email protected],1,1,1,1,1,1,1,1,1,1,0",
"[email protected],1,1,1,1,1,1,1,1,1,0,0",
""
Expand Down Expand Up @@ -47,6 +47,43 @@
}
],
"next": null,
"missing_persons": 0
"missing_persons": 0,
"filters": {
"breakdown_attribution_type": "first_touch",
"breakdown_normalize_url": false,
"breakdown_values": [0],
"date_from": "-11d",
"display": "ActionsTable",
"insight": "RETENTION",
"limit": 100,
"period": "Week",
"retention_type": "retention_first_time",
"returning_entity": {
"id": "$pageview",
"type": "events",
"order": null,
"name": "$pageview",
"custom_name": null,
"math": null,
"math_property": null,
"math_hogql": null,
"math_group_type_index": null,
"properties": {}
},
"sampling_factor": "",
"target_entity": {
"id": "$pageview",
"type": "events",
"order": null,
"name": "$pageview",
"custom_name": null,
"math": null,
"math_property": null,
"math_hogql": null,
"math_group_type_index": null,
"properties": {}
},
"total_intervals": 11
}
}
}
Loading