-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(versioning): prevent deleted segment overrides returning (#3850)
- Loading branch information
1 parent
54c2603
commit 41981d4
Showing
9 changed files
with
199 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import typing | ||
from pathlib import Path | ||
|
||
from django.db.models.query import RawQuerySet | ||
from softdelete.models import SoftDeleteManager | ||
|
||
if typing.TYPE_CHECKING: | ||
from environments.models import Environment | ||
|
||
|
||
with open(Path(__file__).parent.resolve() / "sql/get_latest_versions.sql") as f: | ||
get_latest_versions_sql = f.read() | ||
|
||
|
||
class EnvironmentFeatureVersionManager(SoftDeleteManager): | ||
def get_latest_versions(self, environment: "Environment") -> RawQuerySet: | ||
""" | ||
Get the latest EnvironmentFeatureVersion objects | ||
for a given environment. | ||
""" | ||
return self.raw( | ||
get_latest_versions_sql, params={"environment_id": environment.id} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
select | ||
efv1."uuid", | ||
efv1."published_at", | ||
efv1."live_from" | ||
from | ||
feature_versioning_environmentfeatureversion efv1 | ||
join ( | ||
select | ||
efv2."feature_id", | ||
efv2."environment_id", | ||
MAX(efv2."live_from") as "latest_release" | ||
from | ||
feature_versioning_environmentfeatureversion efv2 | ||
where | ||
efv2."deleted_at" is null | ||
and efv2."published_at" is not null | ||
group by | ||
efv2."feature_id", | ||
efv2."environment_id" | ||
) latest_release_dates on | ||
efv1."feature_id" = latest_release_dates."feature_id" | ||
and efv1."environment_id" = latest_release_dates."environment_id" | ||
and efv1."live_from" = latest_release_dates."latest_release" | ||
where | ||
efv1.environment_id = %(environment_id)s; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters