Skip to content

Commit a94636c

Browse files
Fixes #256: Show changes ahead/behind only for "ready" branches (#274)
* Fixes #256: Show changes ahead/behind only for 'ready' branches * Revert out-of-scope change
1 parent 8fa98b4 commit a94636c

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

netbox_branching/models/branches.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -204,32 +204,32 @@ def get_unsynced_changes(self):
204204
"""
205205
Return a queryset of all ObjectChange records created in main since the Branch was last synced or created.
206206
"""
207-
if self.status not in BranchStatusChoices.WORKING:
208-
return ObjectChange.objects.none()
209-
return ObjectChange.objects.using(DEFAULT_DB_ALIAS).exclude(
210-
application__branch=self
211-
).filter(
212-
changed_object_type__in=get_branchable_object_types(),
213-
time__gt=self.synced_time
214-
)
207+
if self.status == BranchStatusChoices.READY:
208+
return ObjectChange.objects.using(DEFAULT_DB_ALIAS).exclude(
209+
application__branch=self
210+
).filter(
211+
changed_object_type__in=get_branchable_object_types(),
212+
time__gt=self.synced_time
213+
)
214+
return ObjectChange.objects.none()
215215

216216
def get_unmerged_changes(self):
217217
"""
218218
Return a queryset of all unmerged ObjectChange records within the Branch schema.
219219
"""
220-
if self.status not in BranchStatusChoices.WORKING:
221-
return ObjectChange.objects.none()
222-
return ObjectChange.objects.using(self.connection_name)
220+
if self.status == BranchStatusChoices.READY:
221+
return ObjectChange.objects.using(self.connection_name)
222+
return ObjectChange.objects.none()
223223

224224
def get_merged_changes(self):
225225
"""
226226
Return a queryset of all merged ObjectChange records for the Branch.
227227
"""
228-
if self.status not in (BranchStatusChoices.MERGED, BranchStatusChoices.ARCHIVED):
229-
return ObjectChange.objects.none()
230-
return ObjectChange.objects.using(DEFAULT_DB_ALIAS).filter(
231-
application__branch=self
232-
)
228+
if self.status in (BranchStatusChoices.MERGED, BranchStatusChoices.ARCHIVED):
229+
return ObjectChange.objects.using(DEFAULT_DB_ALIAS).filter(
230+
application__branch=self
231+
)
232+
return ObjectChange.objects.none()
233233

234234
def get_event_history(self):
235235
history = []

0 commit comments

Comments
 (0)