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

[NO-ISSUE] feat: allow to query multiple users (freebusy) #26

Merged

Conversation

GuillaumeDecMeetsMore
Copy link
Collaborator

@GuillaumeDecMeetsMore GuillaumeDecMeetsMore commented Jul 29, 2024

Changed

  • [test] Add tests for querying freebusy on multiple calendars of the same user
  • [feat] Allow to query freebusy on multiple users (all calendars)
  • [test] Adapt test for handling Japanese event names
  • [fix] Adapt code for handling metadata the same way in all entities
  • [test] Adapt test for metadata

GuillaumeDecMeetsMore and others added 30 commits July 11, 2024 11:32
…' into guillaume/feat/add-format-lint-via-biome
…e/refactor/convert-unix-timestamps-to-datetimes
Base automatically changed from guillaume/feat/add-js-docs-client-lib to master August 1, 2024 09:26
@GuillaumeDecMeetsMore GuillaumeDecMeetsMore marked this pull request as ready for review August 15, 2024 06:14
@@ -1,4 +1,5 @@
export DATABASE_URL := "postgresql://postgres:postgres@localhost:45432/nettuscheduler"
export RUST_BACKTRACE := "1"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Print backtrace in case of error

# Run the migrations
cd crates/infra && sqlx migrate run && cd ../..

# Run the tests
cargo nextest run --workspace && cd ..
cargo test --workspace && cd ..
Copy link
Collaborator Author

@GuillaumeDecMeetsMore GuillaumeDecMeetsMore Aug 15, 2024

Choose a reason for hiding this comment

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

Unfortunately the tests should be run sequentially per crate as the DB instance is shared (nextest run all crates in parallel), so for the moment I revert back to cargo test (default test runner)

@GuillaumeDecMeetsMore GuillaumeDecMeetsMore changed the title [NO-ISSUE] feat: allow to query multiple calendars + allow to query on name + al… [NO-ISSUE] feat: allow to query multiple calendars Aug 15, 2024
@GuillaumeDecMeetsMore GuillaumeDecMeetsMore changed the title [NO-ISSUE] feat: allow to query multiple calendars [NO-ISSUE] feat: allow to query multiple calendars (freebusy) Aug 15, 2024
@GuillaumeDecMeetsMore GuillaumeDecMeetsMore changed the title [NO-ISSUE] feat: allow to query multiple calendars (freebusy) [NO-ISSUE] feat: allow to query multiple users (freebusy) Aug 15, 2024
Comment on lines +158 to +164
return {
res: res.res,
status: res.status,
data: {
busy: res.data.busy.map(convertInstanceDates),
},
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fix, it should retun Dates and not strings

@@ -380,12 +380,230 @@ describe('Requirements', () => {
it.todo('To be implemented')
})

describe("Users' calendars can be queried in groups", () => {
it.todo('To be implemented')
describe('Multiple calendars of the same user can be queried at once', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not linked to the new feature of querying on multiple users for freebusy, but worth adding

})

describe("Users' availability can be queried in groups", () => {
it.todo('To be implemented')
describe('Multiple calendars of different users can be queried at once', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is freebusy of multiple users

Copy link

@mm-zacharydavison mm-zacharydavison left a comment

Choose a reason for hiding this comment

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

Satisfying PR! Some questions.

userIds: UUID[]
/**
* Start time of the period to check for freebusy
* @format Date in UTC

Choose a reason for hiding this comment

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

I assume you've thought of this so maybe just catch me up, but:

my expectation as a user of the client would be that I'd be able to query with timezone information, this seems like the main place someone would make a mistake there.

Is there a reason why this expects UTC?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have started looking into a bit more in #28, following the article that Derek shared, but it's a bit more complex than expected (I need to invest more time).

Ideally, I would like (at least) the JS SDK, the Rust SDK and the API to accept any timezone.
The API could still only handle only UTC datetimes internally. In the PR above, I've tried to have timezones everywhere (so, never convert to UTC, but it became quite complex so I decided to focus on the other requirements as this one is not blocking per se

Choose a reason for hiding this comment

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

Good for me, we might need to revisit the API design later though.

The reason I ask is you're going to immediately have this problem I think since we're operating in Tokyo timezone.

scheduler/clients/javascript/lib/userClient.ts Outdated Show resolved Hide resolved
}
}

#[cfg(test)]

Choose a reason for hiding this comment

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

Is it idiomatic to put the test in the same file in Rust?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It depends:

  • it's idiomatic to have unit tests in the same file
  • it's idiomatic to have integration tests in a specific "tests" directory

It's worth noting that having unit tests in the same file allows to access private functions, structs, etc., of that module (as the tests are effectively inside the module)

(source)

Choose a reason for hiding this comment

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

TIL! I like that actually.

userIds: UUID[]
/**
* Start time of the period to check for freebusy
* @format Date in UTC

Choose a reason for hiding this comment

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

Good for me, we might need to revisit the API design later though.

The reason I ask is you're going to immediately have this problem I think since we're operating in Tokyo timezone.

*/
busy: CalendarEventInstance[]
[key: string]: CalendarEventInstance[]

Choose a reason for hiding this comment

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

[nit] Shouldn't this be key: UUID

Choose a reason for hiding this comment

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

@GuillaumeDecMeetsMore minor nit, otherwise LGTM.

}
}

#[cfg(test)]

Choose a reason for hiding this comment

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

TIL! I like that actually.

@GuillaumeDecMeetsMore GuillaumeDecMeetsMore merged commit 8ebfbd1 into master Aug 19, 2024
2 checks passed
@GuillaumeDecMeetsMore GuillaumeDecMeetsMore deleted the guillaume/feat/allow-to-query-free-busy-multiple branch August 19, 2024 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants