Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions content_sync/apis/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,18 @@ def upsert_content_file(
def upsert_content_files(self, query_set: WebsiteContentQuerySet | None = None):
"""Commit all website content, with 1 commit per user, optionally filtering with a QuerySet""" # noqa: E501
if query_set:
content_files = query_set.values_list("updated_by", flat=True).distinct()
content_files = (
query_set.values_list("updated_by", flat=True)
.distinct()
.order_by("updated_by")
)
else:
content_files = (
WebsiteContent.objects.all_with_deleted()
.filter(website=self.website)
.values_list("updated_by", flat=True)
.distinct()
.order_by("updated_by")
)
for user_id in content_files:
self.upsert_content_files_for_user(user_id, query_set)
Expand All @@ -353,11 +358,15 @@ def upsert_content_files_for_user(
"""
Upsert multiple WebsiteContent objects to github in one commit, optionally filtering with a QuerySet
""" # noqa: E501
unsynced_states = ContentSyncState.objects.filter(
Q(content__website=self.website) & Q(content__updated_by=user_id)
).exclude(
Q(current_checksum=F("synced_checksum"), content__deleted__isnull=True)
& Q(synced_checksum__isnull=False)
unsynced_states = (
ContentSyncState.objects.filter(
Q(content__website=self.website) & Q(content__updated_by=user_id)
)
.exclude(
Q(current_checksum=F("synced_checksum"), content__deleted__isnull=True)
& Q(synced_checksum__isnull=False)
)
.order_by("content__id")
)
if query_set:
unsynced_states = unsynced_states.filter(content__in=query_set)
Expand Down
Loading