Skip to content

Commit e3113f3

Browse files
committed
Move segment managers inline and improve naming
1 parent 83ff622 commit e3113f3

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

api/segments/managers.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

api/segments/models.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from django.db import models, transaction
1010
from django_lifecycle import ( # type: ignore[import-untyped]
1111
AFTER_CREATE,
12-
BEFORE_CREATE,
1312
LifecycleModelMixin,
1413
hook,
1514
)
@@ -30,13 +29,24 @@
3029
from metadata.models import Metadata
3130
from projects.models import Project
3231

33-
from .managers import LiveSegmentManager, SegmentManager
34-
3532
ModelT = typing.TypeVar("ModelT", bound=models.Model)
3633

3734
logger = logging.getLogger(__name__)
3835

3936

37+
class SegmentManager(SoftDeleteExportableManager):
38+
pass
39+
40+
41+
class LiveSegmentManager(SoftDeleteExportableManager):
42+
def get_queryset(self): # type: ignore[no-untyped-def]
43+
"""
44+
Returns only the canonical segments, which will always be
45+
the highest version.
46+
"""
47+
return super().get_queryset().filter(id=models.F("version_of"))
48+
49+
4050
class ConfiguredOrderManager(SoftDeleteExportableManager, models.Manager[ModelT]):
4151
setting_name: str
4252

0 commit comments

Comments
 (0)