Skip to content
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

fix: DatePicker by passing in Timezone to API #2770

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion api/v2/memo_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,14 @@ func (s *APIV2Service) GetUserMemosStats(ctx context.Context, request *apiv2pb.G
return nil, status.Errorf(codes.Internal, "failed to list memos")
}

location, err := time.LoadLocation(request.Timezone)
if err != nil {
return nil, status.Errorf(codes.Internal, "invalid timezone location")
}

creationStats := make(map[string]int32)
for _, memo := range memos {
creationStats[time.Unix(memo.CreatedTs, 0).Format("2006-01-02")]++
creationStats[time.Unix(memo.CreatedTs, 0).In(location).Format("2006-01-02")]++
}

response := &apiv2pb.GetUserMemosStatsResponse{
Expand Down
5 changes: 5 additions & 0 deletions proto/api/v2/memo_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ message GetUserMemosStatsRequest {
// name is the name of the user to get stats for.
// Format: users/{username}
string name = 1;

// timezone location
// Format: uses tz identifier
// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
string timezone = 2;
}

message GetUserMemosStatsResponse {
Expand Down
1 change: 1 addition & 0 deletions proto/gen/api/v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,7 @@
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| name | [string](#string) | | name is the name of the user to get stats for. Format: users/{username} |
| timezone | [string](#string) | | timezone location Format: uses tz identifier https://en.wikipedia.org/wiki/List_of_tz_database_time_zones |



Expand Down
Loading
Loading