feat: scope articles by brand
This commit is contained in:
@@ -236,7 +236,7 @@ func seedBusinessData(ctx context.Context, pool *pgxpool.Pool, membershipCfg con
|
||||
return nil, err
|
||||
}
|
||||
|
||||
state.ArticleID, err = ensureArticle(ctx, tx, state.TenantID)
|
||||
state.ArticleID, err = ensureArticle(ctx, tx, state.TenantID, state.BrandID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -563,17 +563,18 @@ func ensureCompetitor(ctx context.Context, tx pgx.Tx, tenantID, brandID int64) e
|
||||
return wrapSeedErr("insert competitor", err)
|
||||
}
|
||||
|
||||
func ensureArticle(ctx context.Context, tx pgx.Tx, tenantID int64) (int64, error) {
|
||||
func ensureArticle(ctx context.Context, tx pgx.Tx, tenantID, brandID int64) (int64, error) {
|
||||
var articleID int64
|
||||
err := tx.QueryRow(ctx, `
|
||||
SELECT a.id
|
||||
FROM articles a
|
||||
JOIN article_versions av ON av.id = a.current_version_id
|
||||
WHERE a.tenant_id = $1
|
||||
AND a.brand_id = $2
|
||||
AND av.title = '北京口腔医院全面测评'
|
||||
AND a.deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`, tenantID).Scan(&articleID)
|
||||
`, tenantID, brandID).Scan(&articleID)
|
||||
if err == nil {
|
||||
return articleID, nil
|
||||
}
|
||||
@@ -582,10 +583,10 @@ func ensureArticle(ctx context.Context, tx pgx.Tx, tenantID int64) (int64, error
|
||||
}
|
||||
|
||||
err = tx.QueryRow(ctx, `
|
||||
INSERT INTO articles (tenant_id, source_type, generate_status, publish_status)
|
||||
VALUES ($1, 'free_create', 'completed', 'published')
|
||||
INSERT INTO articles (tenant_id, brand_id, source_type, generate_status, publish_status)
|
||||
VALUES ($1, $2, 'free_create', 'completed', 'published')
|
||||
RETURNING id
|
||||
`, tenantID).Scan(&articleID)
|
||||
`, tenantID, brandID).Scan(&articleID)
|
||||
if err != nil {
|
||||
return 0, wrapSeedErr("insert article", err)
|
||||
}
|
||||
|
||||
@@ -110,9 +110,6 @@ func main() {
|
||||
if jobCtx.Job != nil && jobCtx.Job.TimeoutSeconds > 0 {
|
||||
timeout = time.Duration(jobCtx.Job.TimeoutSeconds) * time.Second
|
||||
}
|
||||
if timeout <= 0 {
|
||||
timeout = 45 * time.Second
|
||||
}
|
||||
taskCtx, cancel := context.WithTimeout(runCtx, timeout)
|
||||
defer cancel()
|
||||
return monitoringDailyTaskWorker.RunOnce(taskCtx, monitoringDailyRunOptions(jobCtx))
|
||||
|
||||
Reference in New Issue
Block a user