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

Support transactions in models #922

Merged
merged 7 commits into from
Feb 26, 2024
Merged

Support transactions in models #922

merged 7 commits into from
Feb 26, 2024

Conversation

alflennik
Copy link
Contributor

@alflennik alflennik commented Feb 13, 2024

Apologies for the ginormous PR, believe it or not this is only half of the larger effort to implement transaction support.

The file change count is high but most of the changed files only have one line in their imports changed. Also the lines changed is inflated since there's a lot of duplicated code.

Here is a summary of the changes:

  1. Duplicates the server/models/services folder into server/models/services.deprecated
  2. Updates all imports of the model services to this new deprecated folder.

These changes allow the entire system to keep working without changes. This is the strategy I've used to break this larger effort into two PRs.

  1. Updates the server/models/services with a new object-based API, making it way easier than the old positional arguments to supply transactions.
  2. Updates the tests to support the new API. Where tests were missing, I added new tests.
  3. Makes all the models files consistent, CollectionJobService and TestPlanService were both diverging from the other model files and that made this kind of change difficult.

Copy link
Contributor

@howard-e howard-e left a comment

Choose a reason for hiding this comment

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

This is great! Even though you've summarized the PR down to "duplicating services and updating imports", I think a bit more has gone into it than just that! I took note of all the JSDoc updates, restructuring files in some instances to better follow the structure of the <model>Service.js files and a bit of intentionality and care with doing away with older parameter structures.

Excited for when we can get rid of services.deprecated. We've needed this approach for a while!

My inline comments only reflect minor cleanup needs.

Copy link
Collaborator

@Paul-Clue Paul-Clue left a comment

Choose a reason for hiding this comment

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

Hey Thanks for this work!
My main focus of this review is making sure that there are no missing or failing tests for the new object oriented structure of the API. As such, I found a few functions that may be missing tests:

AtService.js
1. removeAtVersionById
2. getUniqueAtVersionsForReport

BrowserService.js
1. removeBrowserVersionByQuery
2. findOrCreateBrowserVersion

CollectionJobService.js
1. scheduleCollectionJob automation/graphql tests only
2. restartCollectionJob automation/graphql tests only
3. cancelCollectionJob automation/graphql tests only
4. retryCanceledCollections graphql tests only

TestPlanReportService.js
1. updateTestPlanReportById
2. removeTestPlanReportById

UserService.js
1. getUserRoles
2. getUserAts
3. bulkGetOrReplaceUserAts
4. deleteUserFromRole

TestsService.js
1. getTests

TestResultWriteService.js
1. findOrCreateTestResult graphql / test plan run tests only

TestResultReadService.js
1. getTestResults
2. getFinalizedTestResults

TestPlanService.js
1. removeTestPlanById

TestPlanRunService.js
1. removeTestPlanRunResultsByQuery
2. getTestResultsUsingAtVersion

Also the parameter (t) that you are using in the new API is not very descriptive. It seems like the t represents transaction. Maybe we can make this param more descriptive in a future PR.

@alflennik
Copy link
Contributor Author

alflennik commented Feb 23, 2024

Hi reviewers, changes since the last review are here: https://github.com/w3c/aria-at-app/pull/922/files/a904404adc1ed8da85d47fe604f233898dc0deb6..73b597c8400f1f3d19f28f49056a57914563badd

There are a lot of changes so I recommend taking a second look.

@Paul-Clue, thanks for listing out those missing tests, while implementing them I actually found a bug and a couple of mislabeled fields so that was a great note.

I didn't implement tests which were already covered elsewhere, but I made sure that all the methods which are universally tested in other services were tested.

About the t variable name, I had a whole speech prepared about how the name t is more efficient when transactions are so ubiquitous, but actually, thinking about it over a few days since your review, I've actually come around and I think you're right. So I renamed t to transaction.

One other thing is that, as I worked on the follow-up PR to this one, I did find a couple more mislabeled fields. I've incorporated those changes into this PR.

Comment on lines 528 to 534
* Gets one CollectionJob and optionally updates it, or creates it if it doesn't exist.
* Gets one CollectionJob and optionally updates it, or creates it if it doesn'transaction exist.
Copy link
Collaborator

Choose a reason for hiding this comment

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

A typo was created here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, nice catch finding this in the voluminous changes 😅

Comment on lines 328 to 330
* Gets one TestPlanReport, or creates it if it doesn't exist, and then optionally updates it. Supports nested / associated values.
* Gets one TestPlanReport, or creates it if it doesn'transaction exist, and then optionally updates it. Supports nested / associated values.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another typo

// shouldn't have duplicate entries for a tester unless it's automated
// shouldn'transaction have duplicate entries for a tester unless it's automated
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo

Copy link
Contributor

@howard-e howard-e left a comment

Choose a reason for hiding this comment

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

LGTM after Paul's comments are addressed. Exciting!

Copy link
Collaborator

@Paul-Clue Paul-Clue left a comment

Choose a reason for hiding this comment

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

It's good to go after fixing those tiny typos!

@alflennik alflennik merged commit cfa1c72 into main Feb 26, 2024
2 checks passed
@alflennik alflennik deleted the model-transactions branch February 26, 2024 16:58
@alflennik alflennik mentioned this pull request Apr 1, 2024
34 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants