Skip to content

Commit 9c4130a

Browse files
committed
fix retention data (hopefully) -- fix some sources of a crash; add index
1 parent fcfd5e7 commit 9c4130a

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/packages/frontend/frame-editors/crm-editor/views/retention.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,21 @@ interface Props {
3333
export default function RetentionView({ retention, setRetention }: Props) {
3434
const all = useMemo(
3535
() => retention.model.endsWith(":all"),
36-
[retention.model]
36+
[retention.model],
3737
);
3838
const [retentionData, setRetentionData] = useState<RetentionData[] | null>(
39-
null
39+
null,
4040
);
4141
const { size, period, startTimes } = useMemo(() => {
4242
let size = 0;
4343
for (const x of retentionData ?? []) {
4444
size += x?.size ?? 0;
4545
}
46-
if (retentionData == null || retentionData.length == 0) {
46+
if (
47+
retentionData == null ||
48+
retentionData.length == 0 ||
49+
retentionData[0] == null
50+
) {
4751
return { size: 0, period: 0, startTimes: [] };
4852
}
4953
const { start, active, last_start_time } = retentionData[0];
@@ -132,7 +136,7 @@ function Header({ size, period, startTimes, all }) {
132136
<>
133137
{dayjs(t[0]).format("dd MMM D, YYYY h:mm A")} -{" "}
134138
{dayjs(t[0].add(period, "milliseconds")).format(
135-
"dd MMM D, YYYY h:mm A"
139+
"dd MMM D, YYYY h:mm A",
136140
)}{" "}
137141
{all ? "all active users" : "first cohort active users"}
138142
</>
@@ -188,7 +192,7 @@ function Row({ start, stop, size, active, period, all }) {
188192
{n} active {plural(n, "user")}
189193
</>
190194
)}
191-
/>
195+
/>,
192196
);
193197
}
194198
}

src/packages/frontend/frame-editors/crm-editor/views/retention/update.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ export default async function update(
101101
},
102102
);
103103
}
104-
data.push(result.query.crm_retention);
104+
if (result.query.crm_retention != null) {
105+
data.push(result.query.crm_retention);
106+
}
105107

106108
// Update interval for next iteration
107109
n += 1;

src/packages/util/db-schema/project-log.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Table({
1818
//db_standby: "unsafe",
1919
durability: "soft", // dropping a log entry (e.g., "foo opened a file") wouldn't matter much
2020

21-
pg_indexes: ["project_id", "time"],
21+
pg_indexes: ["project_id", "time", "account_id"],
2222

2323
user_query: {
2424
get: {

0 commit comments

Comments
 (0)