Skip to content

feat(site): add support for weekly data on template insights #9997

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

Merged
merged 20 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Update chart to support weekly data
  • Loading branch information
BrunoQuaresma committed Oct 2, 2023
commit 6b4e763f3a912d4ff6cd6ec1618e8f2510c628dd
8 changes: 6 additions & 2 deletions site/src/components/ActiveUserChart/ActiveUserChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ ChartJS.register(

export interface ActiveUserChartProps {
data: { date: string; amount: number }[];
interval: "day" | "week";
}

export const ActiveUserChart: FC<ActiveUserChartProps> = ({ data }) => {
export const ActiveUserChart: FC<ActiveUserChartProps> = ({
data,
interval,
}) => {
const theme: Theme = useTheme();

const labels = data.map((val) => {
Expand Down Expand Up @@ -85,7 +89,7 @@ export const ActiveUserChart: FC<ActiveUserChartProps> = ({ data }) => {
},
type: "time",
time: {
unit: "day",
unit: interval,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const GeneralSettingsPageView = ({
{deploymentDAUs && (
<Box height={200} sx={{ mb: 3 }}>
<ChartSection title={<ActiveUsersTitle />}>
<ActiveUserChart data={deploymentDAUs.entries} />
<ActiveUserChart data={deploymentDAUs.entries} interval="day" />
</ChartSection>
</Box>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export default function TemplateInsightsPage() {
}
templateInsights={templateInsights}
userLatency={userLatency}
interval={interval}
/>
</>
);
Expand All @@ -121,10 +122,12 @@ export const TemplateInsightsPageView = ({
templateInsights,
userLatency,
controls,
interval,
}: {
templateInsights: TemplateInsightsResponse | undefined;
userLatency: UserLatencyInsightsResponse | undefined;
controls: ReactNode;
interval: InsightsInterval;
}) => {
return (
<>
Expand All @@ -148,6 +151,7 @@ export const TemplateInsightsPageView = ({
>
<ActiveUsersPanel
sx={{ gridColumn: "span 2" }}
interval={interval}
data={templateInsights?.interval_reports}
/>
<UserLatencyPanel data={userLatency} />
Expand All @@ -166,9 +170,11 @@ export const TemplateInsightsPageView = ({

const ActiveUsersPanel = ({
data,
interval,
...panelProps
}: PanelProps & {
data: TemplateInsightsResponse["interval_reports"] | undefined;
interval: InsightsInterval;
}) => {
return (
<Panel {...panelProps}>
Expand All @@ -182,6 +188,7 @@ const ActiveUsersPanel = ({
{data && data.length === 0 && <NoDataAvailable />}
{data && data.length > 0 && (
<ActiveUserChart
interval={interval}
data={data.map((d) => {
return {
amount: d.active_users,
Expand Down