Skip to content

feat: Fix Deployment DAUs to work with local timezones #7647

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 18 commits into from
May 30, 2023
Merged
Prev Previous commit
Next Next commit
Fix FE to use singulare DAUsResponse
  • Loading branch information
Emyrk committed May 23, 2023
commit bf1bd47ea2fdfd639a02d5ebb68ee5322586f930
4 changes: 2 additions & 2 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,13 +826,13 @@ export const getAuditLogs = async (

export const getTemplateDAUs = async (
templateId: string,
): Promise<TypesGen.TemplateDAUsResponse> => {
): Promise<TypesGen.DAUsResponse> => {
const response = await axios.get(`/api/v2/templates/${templateId}/daus`)
return response.data
}

export const getDeploymentDAUs =
async (): Promise<TypesGen.DeploymentDAUsResponse> => {
async (): Promise<TypesGen.DAUsResponse> => {
const response = await axios.get(`/api/v2/insights/daus`)
return response.data
}
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/DAUChart/DAUChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ChartJS.register(
)

export interface DAUChartProps {
daus: TypesGen.TemplateDAUsResponse | TypesGen.DeploymentDAUsResponse
daus: TypesGen.DAUsResponse
}
export const Language = {
loadingText: "DAU stats are loading. Check back later.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Sidebar } from "./Sidebar"
import { createContext, Suspense, useContext, FC } from "react"
import { useMachine } from "@xstate/react"
import { Loader } from "components/Loader/Loader"
import { DeploymentDAUsResponse } from "api/typesGenerated"
import { DAUsResponse } from "api/typesGenerated"
import { deploymentConfigMachine } from "xServices/deploymentConfig/deploymentConfigMachine"
import { RequirePermission } from "components/RequirePermission/RequirePermission"
import { usePermissions } from "hooks/usePermissions"
Expand All @@ -15,7 +15,7 @@ import { DeploymentConfig } from "api/types"
type DeploySettingsContextValue = {
deploymentValues: DeploymentConfig
getDeploymentValuesError: unknown
deploymentDAUs?: DeploymentDAUsResponse
deploymentDAUs?: DAUsResponse
getDeploymentDAUsError: unknown
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DeploymentOption } from "api/types"
import { DeploymentDAUsResponse } from "api/typesGenerated"
import { DAUsResponse } from "api/typesGenerated"
import { ErrorAlert } from "components/Alert/ErrorAlert"
import { DAUChart } from "components/DAUChart/DAUChart"
import { Header } from "components/DeploySettingsLayout/Header"
Expand All @@ -9,7 +9,7 @@ import { useDeploymentOptions } from "utils/deployOptions"

export type GeneralSettingsPageViewProps = {
deploymentOptions: DeploymentOption[]
deploymentDAUs?: DeploymentDAUsResponse
deploymentDAUs?: DAUsResponse
getDeploymentDAUsError: unknown
}
export const GeneralSettingsPageView = ({
Expand Down
6 changes: 4 additions & 2 deletions site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ export const MockOrganization: TypesGen.Organization = {
updated_at: "",
}

export const MockTemplateDAUResponse: TypesGen.TemplateDAUsResponse = {
export const MockTemplateDAUResponse: TypesGen.DAUsResponse = {
tz_hour_offset: 0,
entries: [
{ date: "2022-08-27T00:00:00Z", amount: 1 },
{ date: "2022-08-29T00:00:00Z", amount: 2 },
{ date: "2022-08-30T00:00:00Z", amount: 1 },
],
}
export const MockDeploymentDAUResponse: TypesGen.DeploymentDAUsResponse = {
export const MockDeploymentDAUResponse: TypesGen.DAUsResponse = {
tz_hour_offset: 0,
entries: [
{ date: "2022-08-27T00:00:00Z", amount: 1 },
{ date: "2022-08-29T00:00:00Z", amount: 2 },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeploymentDAUsResponse } from "./../../api/typesGenerated"
import { DAUsResponse } from "./../../api/typesGenerated"
import { getDeploymentValues, getDeploymentDAUs } from "api/api"
import { createMachine, assign } from "xstate"
import { DeploymentConfig } from "api/types"
Expand All @@ -12,7 +12,7 @@ export const deploymentConfigMachine = createMachine(
context: {} as {
deploymentValues?: DeploymentConfig
getDeploymentValuesError?: unknown
deploymentDAUs?: DeploymentDAUsResponse
deploymentDAUs?: DAUsResponse
getDeploymentDAUsError?: unknown
},
events: {} as { type: "LOAD" },
Expand All @@ -21,7 +21,7 @@ export const deploymentConfigMachine = createMachine(
data: DeploymentConfig
}
getDeploymentDAUs: {
data: DeploymentDAUsResponse
data: DAUsResponse
}
},
},
Expand Down