File tree Expand file tree Collapse file tree 4 files changed +12
-8
lines changed Expand file tree Collapse file tree 4 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ class BatchUpsertPagesJob < ApplicationJob
3
3
queue_as :default
4
4
5
5
def perform ( limit : nil )
6
- Page . upsert_from_sitepress !( limit : limit )
6
+ Page . upsert_collection_from_sitepress !( limit : limit )
7
7
end
8
8
end
9
9
end
Original file line number Diff line number Diff line change @@ -44,18 +44,22 @@ def self.as_published_articles
44
44
SitepressArticle . take_published ( all . map { |page | SitepressArticle . new ( page . resource ) } )
45
45
end
46
46
47
- def self . upsert_from_sitepress !( limit : nil )
47
+ def self . upsert_collection_from_sitepress !( limit : nil )
48
48
# Targeting specific Sitepress models until we have a better way to make
49
49
# Page model aware of published state
50
50
enum = [
51
51
SitepressArticle ,
52
52
SitepressSlashPage
53
53
] . lazy . flat_map { |model | model . all . resources }
54
54
55
- enum = enum . filter do |sitepress_resource |
56
- Page . find_by ( request_path : sitepress_resource . request_path ) . nil?
57
- end . map do |sitepress_resource |
58
- Page . create! ( request_path : sitepress_resource . request_path )
55
+ if limit
56
+ enum = enum . filter do |sitepress_resource |
57
+ Page . find_by ( request_path : sitepress_resource . request_path ) . nil?
58
+ end
59
+ end
60
+
61
+ enum = enum . map do |sitepress_resource |
62
+ upsert_page_from_sitepress! ( sitepress_resource )
59
63
end
60
64
61
65
if limit
Original file line number Diff line number Diff line change 8
8
end
9
9
10
10
it "displays a single article" do
11
- Page . upsert_from_sitepress !( limit : 1 )
11
+ Page . upsert_collection_from_sitepress !( limit : 1 )
12
12
13
13
article = Page . first
14
14
article . topics << FactoryBot . create_list ( :topic , 2 , :approved )
Original file line number Diff line number Diff line change 2
2
3
3
RSpec . describe "Topics" , type : :system do
4
4
it "displays the topics and provides navigation links" do
5
- Page . upsert_from_sitepress !( limit : 3 )
5
+ Page . upsert_collection_from_sitepress !( limit : 3 )
6
6
7
7
expect ( Page . count ) . to eq ( 3 )
8
8
You can’t perform that action at this time.
0 commit comments