mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
feat: use tz_offset when doing deployment dau query (#7736)
* Have FE query correct tz_offset data
This commit is contained in:
@ -453,7 +453,7 @@ func (q *fakeQuerier) GetTemplateDAUs(_ context.Context, arg database.GetTemplat
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
date := as.CreatedAt.UTC().Add(time.Duration(arg.TzOffset) * time.Hour).Truncate(time.Hour * 24)
|
date := as.CreatedAt.UTC().Add(time.Duration(arg.TzOffset) * time.Hour * -1).Truncate(time.Hour * 24)
|
||||||
|
|
||||||
dateEntry := seens[date]
|
dateEntry := seens[date]
|
||||||
if dateEntry == nil {
|
if dateEntry == nil {
|
||||||
@ -492,7 +492,7 @@ func (q *fakeQuerier) GetDeploymentDAUs(_ context.Context, tzOffset int32) ([]da
|
|||||||
if as.ConnectionCount == 0 {
|
if as.ConnectionCount == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
date := as.CreatedAt.UTC().Add(time.Duration(tzOffset) * time.Hour).Truncate(time.Hour * 24)
|
date := as.CreatedAt.UTC().Add(time.Duration(tzOffset) * -1 * time.Hour).Truncate(time.Hour * 24)
|
||||||
|
|
||||||
dateEntry := seens[date]
|
dateEntry := seens[date]
|
||||||
if dateEntry == nil {
|
if dateEntry == nil {
|
||||||
|
@ -151,7 +151,7 @@ func TestCache_TemplateUsers(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "tzOffset",
|
name: "tzOffset",
|
||||||
tzOffset: -1,
|
tzOffset: 1,
|
||||||
args: args{
|
args: args{
|
||||||
rows: []database.InsertWorkspaceAgentStatParams{
|
rows: []database.InsertWorkspaceAgentStatParams{
|
||||||
statRow(zebra, dateH(2022, 1, 2, 1)),
|
statRow(zebra, dateH(2022, 1, 2, 1)),
|
||||||
@ -180,7 +180,7 @@ func TestCache_TemplateUsers(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "tzOffsetPreviousDay",
|
name: "tzOffsetPreviousDay",
|
||||||
tzOffset: -6,
|
tzOffset: 6,
|
||||||
args: args{
|
args: args{
|
||||||
rows: []database.InsertWorkspaceAgentStatParams{
|
rows: []database.InsertWorkspaceAgentStatParams{
|
||||||
statRow(zebra, dateH(2022, 1, 2, 1)),
|
statRow(zebra, dateH(2022, 1, 2, 1)),
|
||||||
|
@ -831,8 +831,11 @@ export const getTemplateDAUs = async (
|
|||||||
return response.data
|
return response.data
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getDeploymentDAUs = async (): Promise<TypesGen.DAUsResponse> => {
|
export const getDeploymentDAUs = async (
|
||||||
const response = await axios.get(`/api/v2/insights/daus`)
|
// Default to user's local timezone
|
||||||
|
offset = new Date().getTimezoneOffset() / 60,
|
||||||
|
): Promise<TypesGen.DAUsResponse> => {
|
||||||
|
const response = await axios.get(`/api/v2/insights/daus?tz_offset=${offset}`)
|
||||||
return response.data
|
return response.data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,9 @@ export const deploymentConfigMachine = createMachine(
|
|||||||
{
|
{
|
||||||
services: {
|
services: {
|
||||||
getDeploymentValues: getDeploymentValues,
|
getDeploymentValues: getDeploymentValues,
|
||||||
getDeploymentDAUs: getDeploymentDAUs,
|
getDeploymentDAUs: async () => {
|
||||||
|
return getDeploymentDAUs()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
assignDeploymentValues: assign({
|
assignDeploymentValues: assign({
|
||||||
|
Reference in New Issue
Block a user