Skip to content

Commit

Permalink
fix(analytics): fix CSV name
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Dec 28, 2024
1 parent de09c3b commit 2cf1544
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions apps/frontend/src/pages/Account/Analytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,6 @@ function Charts(props: { accountSlug: string; period: Period }) {
return <Navigate to="/" />;
}

console.log(
getCSVName({
unit: "builds",
from,
to,
groupBy,
}),
);

return (
<div className="grid grid-cols-12 gap-6 lg:flex-row">
<Card className="group col-span-12 flex flex-col lg:col-span-6">
Expand All @@ -229,6 +220,7 @@ function Charts(props: { accountSlug: string; period: Period }) {
exportToCSV({
metric: metrics.builds,
name: getCSVName({
account: accountSlug,
unit: "builds",
from,
to,
Expand Down Expand Up @@ -270,6 +262,7 @@ function Charts(props: { accountSlug: string; period: Period }) {
exportToCSV({
metric: metrics.builds,
name: getCSVName({
account: accountSlug,
unit: "screenshots",
from,
to,
Expand Down Expand Up @@ -383,22 +376,16 @@ function Charts(props: { accountSlug: string; period: Period }) {
}

function getCSVName(props: {
account: string;
unit: string;
from: Date;
to: Date;
groupBy: TimeSeriesGroupBy;
}) {
const { unit, from, to, groupBy } = props;
const { account, unit, from, to, groupBy } = props;
const fromStr = from.toISOString().slice(0, 10);
const toStr = to.toISOString().slice(0, 10);
switch (groupBy) {
case TimeSeriesGroupBy.Day:
return `argos-${unit}-${fromStr}-${toStr}.csv`;
case TimeSeriesGroupBy.Week:
return `argos-${unit}-${fromStr}-${toStr}-week.csv`;
case TimeSeriesGroupBy.Month:
return `argos-${unit}-${fromStr}-${toStr}-month.csv`;
}
return `${account}-${unit}-${fromStr}-${toStr}-${groupBy}.csv`;
}

function exportToCSV(props: { metric: Metric; name: string }) {
Expand Down

0 comments on commit 2cf1544

Please sign in to comment.