Skip to content

Release 0.178.3#2906

Closed
odlbot wants to merge 3 commits into
releasefrom
release-candidate
Closed

Release 0.178.3#2906
odlbot wants to merge 3 commits into
releasefrom
release-candidate

Conversation

@odlbot
Copy link
Copy Markdown
Contributor

@odlbot odlbot commented Feb 17, 2026

pt2302

pt2302 and others added 3 commits February 17, 2026 06:45
* Update reset_sync_states management command

* Improve efficiency and messages to user
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @odlbot, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request constitutes release 0.178.3, primarily focusing on an enhancement to the reset_sync_states management command. This update introduces the capability to selectively synchronize content for specific websites, providing more granular control over the content synchronization process.

Highlights

  • reset_sync_states command enhancement: The reset_sync_states management command was updated to allow filtering of specific websites for synchronization, enabling direct syncing of selected sites to their designated backend.
  • Version Update: The project version was incremented to 0.178.3.
Changelog
  • RELEASE.rst
    • Added release notes for version 0.178.3, detailing the update to the reset_sync_states management command.
  • content_sync/management/commands/reset_sync_states.py
    • Imported get_sync_backend, fetch_website, and reset_publishing_fields for new functionality.
    • Implemented logic within the handle method to filter websites based on command-line arguments.
    • Modified the synchronization flow to directly sync filtered websites to their backend, or fall back to the existing asynchronous task for all unsynced websites if no filter is applied.
  • main/settings.py
    • Updated the VERSION string from "0.178.2" to "0.178.3".
Activity
  • A commit e24c7e51 was made to update the reset_sync_states management command.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the reset_sync_states management command to allow syncing specific websites passed via filters. The changes are generally good, but I've identified a few areas for improvement related to performance, potential rate-limiting issues, and code maintainability. Specifically, there's an N+1 query when fetching websites, a missing call to throttle backend API calls which could lead to rate-limiting, and some code duplication that could be refactored.

Comment on lines +70 to +72
filtered_websites = [
fetch_website(site_identifier) for site_identifier in self.filter_list
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This list comprehension executes a separate database query for each site identifier in self.filter_list. This can lead to performance issues (N+1 queries) if the list of sites is large. It would be more efficient to fetch all the websites in a single bulk query.

            from websites.models import Website
            from django.db.models import Q

            filtered_websites = []
            if self.filter_list:
                filtered_websites = list(Website.objects.filter(
                    Q(name__in=self.filter_list) | Q(short_id__in=self.filter_list)
                ))

Comment on lines +107 to +121
for website in filtered_websites:
backend = get_sync_backend(website)
if create_backends or backend.backend_exists():
self.stdout.write(
f"Syncing website '{website.title}' to backend..."
)
backend.create_website_in_backend()
backend.sync_all_content_to_backend()
reset_publishing_fields(website.name)
else:
self.stderr.write(
f"Skipping website '{website.title}': "
"backend does not exist "
"(use --create_backends to create it)"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The loop for syncing filtered websites performs backend operations but does not include throttling. The sync_unsynced_websites task calls api.throttle_git_backend_calls to prevent hitting API rate limits. This is especially important for git-based backends when syncing a large number of websites. Please add a call to api.throttle_git_backend_calls(backend) within the loop.

                for website in filtered_websites:
                    backend = get_sync_backend(website)
                    from content_sync.api import throttle_git_backend_calls
                    throttle_git_backend_calls(backend)
                    if create_backends or backend.backend_exists():
                        self.stdout.write(
                            f"Syncing website '{website.title}' to backend..."
                        )
                        backend.create_website_in_backend()
                        backend.sync_all_content_to_backend()
                        reset_publishing_fields(website.name)
                    else:
                        self.stderr.write(
                            f"Skipping website '{website.title}': "
                            "backend does not exist "
                            "(use --create_backends to create it)"
                        )

Comment on lines +102 to +128
if filtered_websites:
self.stdout.write(
f"Syncing {len(filtered_websites)} filtered "
"website(s) to the designated backend"
)
for website in filtered_websites:
backend = get_sync_backend(website)
if create_backends or backend.backend_exists():
self.stdout.write(
f"Syncing website '{website.title}' to backend..."
)
backend.create_website_in_backend()
backend.sync_all_content_to_backend()
reset_publishing_fields(website.name)
else:
self.stderr.write(
f"Skipping website '{website.title}': "
"backend does not exist "
"(use --create_backends to create it)"
)
else:
self.stdout.write(
"Syncing all unsynced websites to the designated backend"
)
task = sync_unsynced_websites.delay(create_backends=create_backends)
self.stdout.write(f"Starting task {task}...")
task.get()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for syncing a website inside the if filtered_websites: block is very similar to the logic inside the sync_unsynced_websites Celery task. This duplication could make future maintenance harder. Also, there's an inconsistency: reset_publishing_fields is called after syncing here, but before syncing in the task. Consider refactoring the common logic into a shared function to improve maintainability and ensure consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants