feat: add brand asset cleanup worker and related functionality
Frontend CI / Frontend (push) Successful in 3m23s
Backend CI / Backend (push) Failing after 6m46s

- Implemented a new BrandAssetCleanupWorker to handle the cleanup of brand-related assets after a brand is deleted.
- Added SQL queries for cleaning up articles, keywords, questions, competitors, and monitoring data associated with a brand.
- Introduced a new API endpoint to delete publish records.
- Updated the router to include the new delete publish record endpoint.
- Added tests for the BrandAssetCleanupWorker to ensure proper functionality.
- Created migration scripts to support soft deletion of publish records and to add the brand asset cleanup scheduler job.
This commit is contained in:
2026-06-19 11:45:13 +08:00
parent 97ae601cfd
commit 6e0519a232
29 changed files with 1621 additions and 54 deletions
@@ -0,0 +1,2 @@
DELETE FROM ops.scheduler_jobs
WHERE job_key = 'brand_asset_cleanup';
@@ -0,0 +1,17 @@
INSERT INTO ops.scheduler_jobs
(job_key, display_name, category, description, enabled, schedule_type, interval_seconds, timezone, timeout_seconds, batch_size, config)
VALUES
('brand_asset_cleanup', '品牌资产后台清理', 'tenant', '删除品牌后静默清理该品牌下的文章、词库、竞品和监控采集数据;发布记录作为用户发文总账保留。', true, 'interval', 60, 'Asia/Shanghai', 120, 20,
'{"batch_size":20,"statement_timeout":"8s","dry_run":false}'::jsonb)
ON CONFLICT (job_key) DO UPDATE
SET display_name = EXCLUDED.display_name,
category = EXCLUDED.category,
description = EXCLUDED.description,
enabled = EXCLUDED.enabled,
schedule_type = EXCLUDED.schedule_type,
interval_seconds = EXCLUDED.interval_seconds,
timezone = EXCLUDED.timezone,
timeout_seconds = EXCLUDED.timeout_seconds,
batch_size = EXCLUDED.batch_size,
config = ops.scheduler_jobs.config || EXCLUDED.config,
updated_at = NOW();