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

Better encapsulate diesel's connection to ease the split of editoast_models #8712

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

Wadjetz
Copy link
Member

@Wadjetz Wadjetz commented Sep 3, 2024

Create an abstraction of the diesel database connection and transactions

part of the #6980

How to test this PR:

  • Make sure everything work as before
  • No deadlocks in tests

@Wadjetz Wadjetz self-assigned this Sep 3, 2024
@Wadjetz Wadjetz force-pushed the ebe/editoast-db-connection-v3 branch from 4e04a73 to 7aa1016 Compare September 3, 2024 10:23
@codecov-commenter
Copy link

codecov-commenter commented Sep 3, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 83.22440% with 77 lines in your changes missing coverage. Please review.

Project coverage is 37.01%. Comparing base (5e3ca65) to head (6b27efa).
Report is 4 commits behind head on dev.

Files with missing lines Patch % Lines
editoast/src/views/timetable/stdcm.rs 0.00% 17 Missing ⚠️
editoast/src/views/train_schedule/projection.rs 0.00% 10 Missing ⚠️
editoast/src/views/timetable.rs 0.00% 8 Missing ⚠️
editoast/src/views/train_schedule.rs 68.18% 7 Missing ⚠️
editoast/editoast_models/src/db_connection_pool.rs 91.83% 4 Missing ⚠️
editoast/src/views/infra/mod.rs 84.00% 4 Missing ⚠️
editoast/src/views/rolling_stock.rs 71.42% 4 Missing ⚠️
editoast/src/modelsv2/auth.rs 89.65% 3 Missing ⚠️
editoast/src/views/infra/edition.rs 85.00% 3 Missing ⚠️
editoast/src/views/infra/routes.rs 62.50% 3 Missing ⚠️
... and 10 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #8712      +/-   ##
============================================
+ Coverage     36.98%   37.01%   +0.03%     
  Complexity     2208     2208              
============================================
  Files          1255     1255              
  Lines        113843   113901      +58     
  Branches       3188     3188              
============================================
+ Hits          42103    42164      +61     
+ Misses        69845    69842       -3     
  Partials       1895     1895              
Flag Coverage Δ
core 74.73% <ø> (ø)
editoast 72.15% <83.22%> (+0.07%) ⬆️
front 14.97% <ø> (ø)
gateway 2.20% <ø> (ø)
osrdyne 2.71% <ø> (ø)
railjson_generator 87.49% <ø> (ø)
tests 86.37% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Wadjetz Wadjetz force-pushed the ebe/editoast-db-connection-v3 branch from 7aa1016 to 5d72b07 Compare September 3, 2024 10:44
@Wadjetz Wadjetz changed the title editoast: db connection v3 editoast: db connection abstraction Sep 3, 2024
@Wadjetz Wadjetz added area:editoast Work on Editoast Service kind:tests Writing unit / e2e and integration tests kind:refacto-task Task related to Refactorization Epic labels Sep 3, 2024
@Wadjetz Wadjetz force-pushed the ebe/editoast-db-connection-v3 branch 8 times, most recently from 2dccbce to bd34c1a Compare September 3, 2024 14:52
@Wadjetz Wadjetz marked this pull request as ready for review September 3, 2024 15:16
@Wadjetz Wadjetz requested a review from a team as a code owner September 3, 2024 15:16
@Wadjetz Wadjetz force-pushed the ebe/editoast-db-connection-v3 branch from bd34c1a to c93f95e Compare September 3, 2024 17:38
Copy link
Contributor

@woshilapin woshilapin left a comment

Choose a reason for hiding this comment

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

Big work, will be much better. Thank you 🎉

I request a change on the documentation of the re-implementation of transaction since it's a central but non-trivial function of this new DbConnection. I believe it's important to give as much context as possible to ease future maintenance.

editoast/src/modelsv2/fixtures.rs Outdated Show resolved Hide resolved
@woshilapin woshilapin force-pushed the ebe/editoast-db-connection-v3 branch from c93f95e to b156a58 Compare September 5, 2024 08:43
Copy link
Contributor

@leovalais leovalais left a comment

Choose a reason for hiding this comment

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

Huge work! I have a few comments about the API, especially for errors.

That's work for another PR since this one is already massive:

  1. Most functions don't require a conn: &mut DbConnection but rather just a conn: DbConnection which became cheap to clone.
  2. Maybe we could implement Future for DbConnection so that conn.await <=> conn.write().await.deref_mut()
  3. Some sync test util functions might declutter the boilerplate the RwLock introduced.

editoast/editoast_derive/src/model.rs Outdated Show resolved Hide resolved
editoast/editoast_models/src/lib.rs Outdated Show resolved Hide resolved
editoast/editoast_models/src/lib.rs Outdated Show resolved Hide resolved
editoast/src/modelsv2/auth.rs Outdated Show resolved Hide resolved
@leovalais leovalais force-pushed the ebe/editoast-db-connection-v3 branch from be0e9b3 to 7fcf853 Compare September 5, 2024 13:45
Co-authored-by: Jean SIMARD <[email protected]>
Co-authored-by: Léo VALAIS <[email protected]>
@leovalais leovalais force-pushed the ebe/editoast-db-connection-v3 branch from 7fcf853 to 6b27efa Compare September 5, 2024 14:00
@leovalais leovalais changed the title editoast: db connection abstraction Better encapsulate diesel's connection to ease the split of editoast_models Sep 5, 2024
Copy link
Contributor

@leovalais leovalais left a comment

Choose a reason for hiding this comment

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

Approving in order not to block the PR, but since I made the modifications myself, this doesn't account for much 🤣

@leovalais leovalais added this pull request to the merge queue Sep 5, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 5, 2024
@leovalais leovalais added this pull request to the merge queue Sep 5, 2024
Merged via the queue into dev with commit fcd9734 Sep 5, 2024
22 checks passed
@leovalais leovalais deleted the ebe/editoast-db-connection-v3 branch September 5, 2024 16:09
@leovalais leovalais mentioned this pull request Sep 25, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:editoast Work on Editoast Service kind:refacto-task Task related to Refactorization Epic kind:tests Writing unit / e2e and integration tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants