Skip to content

Commit 1776cff

Browse files
committed
Use Page.published scope for analyzing topics
1 parent a2b0181 commit 1776cff

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

app/jobs/pages/batch_analyze_topics_job.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ class BatchAnalyzeTopicsJob < ApplicationJob
33
queue_as :default
44

55
def perform
6-
scope = Page.where.missing(:topics)
7-
.and(Page.where(request_path: SitepressArticle.published.map(&:request_path)))
8-
9-
scope.find_each do |page|
6+
Page.published.where.missing(:topics).find_each do |page|
107
Pages::AnalyzeTopicsJob.perform_later(page)
118
end
129
end

spec/jobs/pages/batch_analyze_topics_job_spec.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66

77
topics = FactoryBot.create_list(:topic, 2)
88

9+
page_1, page_2, page_3 = Page.upsert_collection_from_sitepress!(limit: 3).each do |page|
10+
page.touch(:published_at)
11+
end
12+
913
# articles without topics
10-
Page.find_or_create_by!(request_path: "/articles/custom-color-schemes-with-ruby-on-rails")
11-
Page.find_or_create_by!(request_path: "/articles/mastering-custom-configuration-in-rails")
14+
page_1.update!(topics: [])
15+
page_2.update!(topics: [])
1216

1317
# articles with topics
14-
Page.find_or_create_by!(request_path: "/articles/web-push-notifications-from-rails")
15-
.update!(topics: topics)
18+
page_3.update!(topics: topics)
1619

1720
# not articles
1821
FactoryBot.create_list(:page, 3)

0 commit comments

Comments
 (0)