Implement boost_endpoint#50
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughAdds a Django-backed BoostComponentService that scans cloned repos to create/update/delete Weblate projects/components/translations, moves add-or-update work to a Celery task, updates DRF views to report version/capabilities and enqueue tasks, and adjusts serializers, coverage, and tests accordingly. ChangesAsync Background Component Sync Feature
Sequence Diagram(s)sequenceDiagram
participant Client
participant DRFView
participant CeleryTask
participant BoostComponentService
participant WeblateDB
Client->>DRFView: POST /add-or-update (validated)
DRFView->>CeleryTask: boost_add_or_update_task.delay(args with user_id)
CeleryTask->>BoostComponentService: process_all(submodules, user, request)
BoostComponentService->>WeblateDB: get_or_create Project / Component / add_new_language
BoostComponentService->>WeblateDB: delete or update component records
CeleryTask-->>DRFView: task_id (immediate)
DRFView-->>Client: 202 Accepted with task_id
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/boost_weblate/endpoint/serializers.py`:
- Around line 35-36: The extensions ListField currently allows blank strings
which makes [""] be treated as a non-empty filter by
BoostComponentService.get_supported_extensions(); update the serializer to
either set child=serializers.CharField(allow_blank=False) or (preferred)
add/modify validate_extensions(self, value) to strip/filter out
empty/whitespace-only strings (e.g., [v for v in value if v.strip()]) and return
the cleaned list so that an all-empty submission falls back to "use all
supported extensions" behavior when passed to
BoostComponentService.get_supported_extensions().
In `@src/boost_weblate/endpoint/services.py`:
- Around line 819-830: The permission check builds the wrong project slug
(boost-{submodule}-documentation) so existing projects created by
get_or_create_project (which uses boost-{submodule}-documentation-{lang_code})
are never found; update the slug construction in the permission gate to include
the language code the same way get_or_create_project does (use the same
lang_code variable/logic or call/get the exact slug from get_or_create_project)
so existing_project lookup and the subsequent user.has_perm("project.edit",
existing_project) check target the correct Project instance before falling back
to project.add; modify the code around project_slug, existing_project, and their
permission checks accordingly.
- Around line 842-850: The loop over configs currently ignores cases where
create_or_update_component(...) returns None but later the submodule is marked
success regardless; change logic so when create_or_update_component(project,
submodule, config, ...) returns None you mark the submodule as failed (e.g., set
success = False and increment a failure counter or add to
result["components_failed"]) and do not increment
components_created/components_updated; ensure the final assignment that sets
success (the variable used around line 865) is only true if at least one
component actually succeeded (was_created True or updated), and propagate
failure when all configs returned None so the async task sees the failure.
- Around line 404-430: The get_or_create branch only applies component_defaults
on create, so when created is False you must merge in changed fields; in the
else branch (after "Component exists") compare and set each field that can
change (e.g. name, repo, push, branch, filemask, template, new_base, file_format
and push_branch) against component_defaults or the incoming values (from
component_defaults/component_slug/repo/… in this scope), append their attribute
names to update_fields when different, then call
component.save(update_fields=update_fields) if any changes; preserve existing
lines that set component.acting_user and the current push_branch logic and
ensure not to call post_create or _sync_component_for_translation in the
non-created path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c18aa138-5b3d-49a4-9802-b6888ebb3e3e
📒 Files selected for processing (7)
pyproject.tomlsrc/boost_weblate/endpoint/serializers.pysrc/boost_weblate/endpoint/services.pysrc/boost_weblate/endpoint/tasks.pysrc/boost_weblate/endpoint/views.pytests/endpoint/test_services.pytests/endpoint/test_views.py
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/boost_weblate/endpoint/services.py (1)
844-877:⚠️ Potential issue | 🟠 Major | ⚡ Quick winPropagate language-add failures into submodule success.
Line 848 only treats
Noneas a failed config, butcreate_or_update_component()still returns a non-Nonecomponent whenadd_language_to_component()returnsFalse. That means permission/template/language-availability failures are counted as created/updated here, and Line 872 can mark the submodule successful even though the requested translation was never added.Please return the add-language outcome from
create_or_update_component()(or returnNoneon that path) and keepsuccessfalse whenever any scanned config failed end-to-end.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/boost_weblate/endpoint/services.py` around lines 844 - 877, The loop treats any non-None component as success even when create_or_update_component() internally failed to add the requested language (via add_language_to_component()), so propagate that failure: change create_or_update_component() to return an explicit success flag for the full end-to-end config (or return None when add_language_to_component() returns False) and update this loop to treat that flag as a failure (increment components_failed and append error) instead of counting it as created/updated; ensure truncate_component_slug, project.component_set iteration and _delete_component_and_commit_removal logic remain unchanged while using the new return shape from create_or_update_component().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/boost_weblate/endpoint/services.py`:
- Around line 844-877: The loop treats any non-None component as success even
when create_or_update_component() internally failed to add the requested
language (via add_language_to_component()), so propagate that failure: change
create_or_update_component() to return an explicit success flag for the full
end-to-end config (or return None when add_language_to_component() returns
False) and update this loop to treat that flag as a failure (increment
components_failed and append error) instead of counting it as created/updated;
ensure truncate_component_slug, project.component_set iteration and
_delete_component_and_commit_removal logic remain unchanged while using the new
return shape from create_or_update_component().
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b42485d9-f526-42e9-a978-25e5b9ac57e4
📒 Files selected for processing (2)
src/boost_weblate/endpoint/serializers.pysrc/boost_weblate/endpoint/services.py
|
@coderabbitai, resume |
|
✅ Actions performedReviews resumed. |
Close #42.
Close #43.
Close #44.
Close #45.
Summary by CodeRabbit
New Features
Improvements
Tests
Chores