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

Create tables for code review v2 #45940

Merged
merged 2 commits into from Apr 25, 2022

Conversation

jamescodeorg
Copy link
Contributor

@jamescodeorg jamescodeorg commented Apr 22, 2022

Creating tables for code review v2 as described in the tech spec.

This is using the old pattern for deleted_at which we know to be flawed. I will migrate to the new pattern in a separate PR once we figure out what the new pattern should be.

Links

Testing story

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@jamescodeorg jamescodeorg requested a review from a team as a code owner April 22, 2022 00:17
@jamescodeorg jamescodeorg force-pushed the jamescodeorg/create-code-review-tables branch from 4fb5fe9 to b426f8c Compare April 22, 2022 00:19

t.timestamps

t.index [:user_id, :script_id, :level_id, :closed_at, :deleted_at],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, closed_at will have the same flaw as deleted_at -- it is possible to have multiple rows with closed_at equal to null. Once we figure out what the correct pattern is for deleted_at, I will apply it to closed_at as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does closed_at need to be included in this index at all? I was expecting, based on the spec, a code review to be unique across a user, script, and level. It seems like deleted_at is there to be able to reset progress, so that also makes sense in the index. But I can't see how closed_at factors into this uniqueness

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding from the spec (which I'm now questioning 😄) is that, for a given script+level, we want to allow the author to open and close review requests multiple times. I think this means that we need to allow multiple code review requests for a given user, script, and level. We also probably want to enforce that there is only one open code review request for a given user, script, and level at any time. Right? (cc: @maureensturgeon)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I confirmed with Maureen that we want to enforce that there is at most one non-closed, non-deleted code_review_request row per user_id + script_id + level_id. Does this index look like it matches that intent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I confirmed with Maureen that we want to enforce that there is at most one non-closed, non-deleted code_review_request row per user_id + script_id + level_id. Does this index look like it matches that intent?

Copy link
Contributor

Choose a reason for hiding this comment

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

The spec says that code reviews cannot be reopened, so I assumed that we would want to enforce that there was one non-deleted code_review_request per user_id + script_id + level_id. But if the goal of this index is only to enforce that one non-deleted, non-closed row exists on these axis then this index makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohhhh. I took that to mean that we can't reopen a closed code review but we could open a new one against a given user_id, script_id, level_id. Thanks for pushing on this, let me check with Maureen.

Copy link
Contributor

Choose a reason for hiding this comment

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

aha! that would make a lot of sense then and this index would look good

@jamescodeorg jamescodeorg requested review from a team April 22, 2022 00:27
@jamescodeorg jamescodeorg force-pushed the jamescodeorg/create-code-review-tables branch from 6fd72b6 to d1f2aa0 Compare April 22, 2022 17:09
@jamescodeorg jamescodeorg merged commit da4d934 into staging Apr 25, 2022
@jamescodeorg jamescodeorg deleted the jamescodeorg/create-code-review-tables branch April 25, 2022 17:52
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.

None yet

3 participants