Add consolidation of duplicate LocalSiteProfile objects.
Review Request #12471 — Created July 14, 2022 and submitted
We had two problems that were potentially causing the existence of
duplicateLocalSiteProfilemodels. The first of these is that this
wasn't usingConcurrencyManager, which handles integrity issues across
separate threads (or servers). The second, more difficult one, is that
some databases (particularly MySQL) were ignoring our unique_together
constraint when one of the relations was NULL. This meant it was
possible to end up with multipleLocalSiteProfileobjects with
local_site=None.This change moves us over to
ConcurrencyManager, and implements a
check for the duplicate case when attempting to use
User.get_site_profile. If we do find duplicates, they'll be
consolidated into a single one before returning.
Ran unit tests.
| Summary | ID |
|---|---|
| a86e6b05cdefb853369e80ef04d5582c4db09faf |
| Description | From | Last Updated |
|---|---|---|
|
line too long (80 > 79 characters) Column: 80 Error code: E501 |
|
|
|
line too long (82 > 79 characters) Column: 80 Error code: E501 |
|
|
|
'reviewboard.accounts.models.Profile' imported but unused Column: 1 Error code: F401 |
|
|
|
'reviewboard.site.models.LocalSite' imported but unused Column: 1 Error code: F401 |
|
|
|
Can we give create_if_missing a default? |
|
|
|
Most of our code capitalized as "Local Site". Can we have these docs use the same? |
|
|
|
Let's make this a numeric list. Makes it much easier to read what's in which slot. |
|
|
|
Can we do one per line? We should treat these like a dictionary when we have multiple keyword args. It's … |
|
|
|
Same as above, can we do one per line? Minimizes changes if we need to update the query. We may … |
|
|
|
We should save all this and permissions using update_fields=, I think? |
|
|
|
Can the paren be moved to the next line, and a trailing comma added? We'll probably need to update this … |
|
|
|
Swap these. |
|
|
|
We should add a step that reloads and verifies resultls. |
|
|
|
line too long (82 > 79 characters) Column: 80 Error code: E501 |
|
|
|
line too long (80 > 79 characters) Column: 80 Error code: E501 |
|
- Commits:
-
Summary ID 99b5d129979cc434333bd6a717ef60fb7fb91cbf f75d2fa605a47d7485491004c54a5ae8a0f12905
Checks run (2 succeeded)
-
-
-
-
-
Can we do one per line? We should treat these like a dictionary when we have multiple keyword args. It's much easier to read and to update.
-
Same as above, can we do one per line? Minimizes changes if we need to update the query.
We may also want to use
.only(...)withpk,permissions, and the counters. Small optimization, and this is unlikely to be called much, so I'll leave that up to you. -
-
-
- Commits:
-
Summary ID f75d2fa605a47d7485491004c54a5ae8a0f12905 9c6f01e643cc3bfd0d23976c2d481edd2e97c419
- Commits:
-
Summary ID 9c6f01e643cc3bfd0d23976c2d481edd2e97c419 a86e6b05cdefb853369e80ef04d5582c4db09faf