[PR #401] [MERGED] Add competitor_analysis fallback and normalization for DeepCompetitorAnalysisTask scheduling #705

Closed
opened 2026-03-13 21:04:48 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AJaySi/ALwrity/pull/401
Author: @AJaySi
Created: 3/9/2026
Status: Merged
Merged: 3/9/2026
Merged by: @AJaySi

Base: mainHead: codex/enhance-competitor-analysis-task-logic


📝 Commits (1)

  • a19a18d Add competitor_analysis fallback for deep competitor task scheduling

📊 Changes

2 files changed (+318 additions, -7 deletions)

View changed files

📝 backend/api/onboarding_utils/onboarding_completion_service.py (+98 -7)
backend/regression_onboarding_completion_service.py (+220 -0)

📄 Description

Motivation

  • Ensure deep competitor analysis is scheduled even when research_preferences.competitors is empty by using persisted integrated_data["competitor_analysis"] as a fallback and improve observability of the source used.

Description

  • Added normalization helpers (_normalize_competitor_analysis_for_deep_task, _normalize_competitor_url, _extract_domain_from_url) to OnboardingCompletionService to convert competitor_analysis records into the {url, domain, name, summary} shape expected by DeepCompetitorAnalysisTask.payload["competitors"] in backend/api/onboarding_utils/onboarding_completion_service.py.
  • Updated complete_onboarding scheduling logic to prefer research_preferences.competitors and fall back to the normalized competitor_analysis when the primary source is empty, to schedule the DeepCompetitorAnalysisTask when either source yields competitors, and to log source counts and the selected source for traceability.
  • Added a regression test that simulates an onboarding completion run where research_preferences.competitors is empty but competitor_analysis exists and asserts a DeepCompetitorAnalysisTask is created with a normalized competitor payload in backend/regression_onboarding_completion_service.py.

Testing

  • Ran the focused regression test with cd backend && pytest -q regression_onboarding_completion_service.py, which completed successfully (1 passed).

Codex Task


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AJaySi/ALwrity/pull/401 **Author:** [@AJaySi](https://github.com/AJaySi) **Created:** 3/9/2026 **Status:** ✅ Merged **Merged:** 3/9/2026 **Merged by:** [@AJaySi](https://github.com/AJaySi) **Base:** `main` ← **Head:** `codex/enhance-competitor-analysis-task-logic` --- ### 📝 Commits (1) - [`a19a18d`](https://github.com/AJaySi/ALwrity/commit/a19a18d9b4abc06fefde4f46840c5ef14c975b59) Add competitor_analysis fallback for deep competitor task scheduling ### 📊 Changes **2 files changed** (+318 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `backend/api/onboarding_utils/onboarding_completion_service.py` (+98 -7) ➕ `backend/regression_onboarding_completion_service.py` (+220 -0) </details> ### 📄 Description ### Motivation - Ensure deep competitor analysis is scheduled even when `research_preferences.competitors` is empty by using persisted `integrated_data["competitor_analysis"]` as a fallback and improve observability of the source used. ### Description - Added normalization helpers (`_normalize_competitor_analysis_for_deep_task`, `_normalize_competitor_url`, `_extract_domain_from_url`) to `OnboardingCompletionService` to convert `competitor_analysis` records into the `{url, domain, name, summary}` shape expected by `DeepCompetitorAnalysisTask.payload["competitors"]` in `backend/api/onboarding_utils/onboarding_completion_service.py`. - Updated `complete_onboarding` scheduling logic to prefer `research_preferences.competitors` and fall back to the normalized `competitor_analysis` when the primary source is empty, to schedule the `DeepCompetitorAnalysisTask` when either source yields competitors, and to log source counts and the selected source for traceability. - Added a regression test that simulates an onboarding completion run where `research_preferences.competitors` is empty but `competitor_analysis` exists and asserts a `DeepCompetitorAnalysisTask` is created with a normalized competitor payload in `backend/regression_onboarding_completion_service.py`. ### Testing - Ran the focused regression test with `cd backend && pytest -q regression_onboarding_completion_service.py`, which completed successfully (`1 passed`). ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_69abc225ff18832897e8e0c0f2de6fc9) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-13 21:04:48 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ALwrity#705
No description provided.