Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: use tz_offset when doing deployment dau query#7736

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 7 commits intomainfromstevenmasley/dau_fe_timezone
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
4 changes: 2 additions & 2 deletionscoderd/database/dbfake/databasefake.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -453,7 +453,7 @@ func (q *fakeQuerier) GetTemplateDAUs(_ context.Context, arg database.GetTemplat
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)
Copy link
Member

@johnstcnjohnstcnMay 31, 2023
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

🤔 This change didn't break anything... which means that our unit tests probably aren't checking something that they should.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You are half right.

I forgot to change it in the Dau dbfake function, which does break the unit test.

The template test does not break because I reverted the Template DAU to only useUTC again for performance reasons. So this is always0 as the offset.


tl;dr fixing it in the spot that is useddoes break the test


dateEntry := seens[date]
if dateEntry == nil {
Expand DownExpand Up@@ -492,7 +492,7 @@ func (q *fakeQuerier) GetDeploymentDAUs(_ context.Context, tzOffset int32) ([]da
if as.ConnectionCount == 0 {
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]
if dateEntry == nil {
Expand Down
4 changes: 2 additions & 2 deletionscoderd/metricscache/metricscache_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,7 +151,7 @@ func TestCache_TemplateUsers(t *testing.T) {
},
{
name: "tzOffset",
tzOffset:-1,
tzOffset: 1,
args: args{
rows: []database.InsertWorkspaceAgentStatParams{
statRow(zebra, dateH(2022, 1, 2, 1)),
Expand DownExpand Up@@ -180,7 +180,7 @@ func TestCache_TemplateUsers(t *testing.T) {
},
{
name: "tzOffsetPreviousDay",
tzOffset:-6,
tzOffset: 6,
args: args{
rows: []database.InsertWorkspaceAgentStatParams{
statRow(zebra, dateH(2022, 1, 2, 1)),
Expand Down
7 changes: 5 additions & 2 deletionssite/src/api/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -831,8 +831,11 @@ export const getTemplateDAUs = async (
return response.data
}

export const getDeploymentDAUs = async (): Promise<TypesGen.DAUsResponse> => {
const response = await axios.get(`/api/v2/insights/daus`)
export const getDeploymentDAUs = async (
// 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
}

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -64,7 +64,9 @@ export const deploymentConfigMachine = createMachine(
{
services: {
getDeploymentValues: getDeploymentValues,
getDeploymentDAUs: getDeploymentDAUs,
getDeploymentDAUs: async () => {
return getDeploymentDAUs()
},
},
actions: {
assignDeploymentValues: assign({
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp