sutty-migration 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8de345679f1c94e0bda19ea99e7d454924bf5aa86c0281bc6a61feab84a3a1cd
4
- data.tar.gz: 5c62c2f467dafb6bc822dbe7c334280776ee173fea3a045cf90cc401030558b2
3
+ metadata.gz: 0dc6ffbe6f1f29803b5690efe018a561dab4e95a85dbfe395da76c6b0a63244f
4
+ data.tar.gz: ae4a2582cfd7742dbb870bd06da9088987e6b65328c40933a507d35ef06e8a56
5
5
  SHA512:
6
- metadata.gz: f1a13ba1cb0c5e75ffc2aae11225b83cc8ee426ccc2c5b3f5e6a8ea6d52df0dee569f67cb4d1319a8f635279edf07604b05ac2ecbc3f66797b046bfe66a14495
7
- data.tar.gz: 2d0fc815a65e19ff74bac83298e71f288b5daf5bd2ab141028eaec6a048e1a27903a9e804638b29cf8b6f13302077f161ff7f253d3e0d3b75b561840c59c54d6
6
+ metadata.gz: cd672998fd7f86b7b1f5c3992ce4d0db017d2eeacf8ca92cccbe0620016bd6bea183a933641083791b7abf14cf4a5d934d4e50589eae9d62b334ef8a403bf629
7
+ data.tar.gz: 6b51a2e800cb0a707cd0a36bda70a4d8aad07a33a63c0e22899be96c1e7a9e524227a735f37282d7066ef46cba2455e948cfc9346f5155df45235bf3c27852fc
@@ -24,14 +24,15 @@ module SuttyMigration
24
24
  collection = site.collections[collection] if collection.is_a? String
25
25
  slug = ::Jekyll::Utils.slugify(title, mode: 'latin') if slug.blank?
26
26
  basename = "#{date.strftime('%F')}-#{slug}.markdown"
27
- path = File.join(collection.directory, basename)
27
+ path = File.join(collection.relative_directory, basename)
28
28
 
29
29
  raise DocumentExists, "#{path} already exists" if File.exist? path
30
30
 
31
- ::Jekyll::Document.new(path, site: site, collection: collection).tap do |document|
32
- collection.docs << document
33
- document.data['title'] = title
34
- end
31
+ indexed_documents_by_relative_path(site)[path] =
32
+ ::Jekyll::Document.new(path, site: site, collection: collection).tap do |document|
33
+ collection.docs << document
34
+ document.data['title'] = title
35
+ end
35
36
  end
36
37
 
37
38
  # Finds a document by its relative path or creates it if it
@@ -229,8 +229,8 @@ module SuttyMigration
229
229
  #{', f.front_matter as front_matter' if with_meta}
230
230
  #{', t.terms as terms' if with_meta}
231
231
  from #{prefix}posts as p
232
- #{"left join (#{meta_query}) as f on f.post_id = p.ID" if with_meta}
233
- #{"left join (#{terms_query}) as t on t.post_id = p.ID" if with_meta}
232
+ #{"left join (#{meta_query(layout: layout)}) as f on f.post_id = p.ID" if with_meta}
233
+ #{"left join (#{terms_query(layout: layout)}) as t on t.post_id = p.ID" if with_meta}
234
234
  #{"where p.post_type = '#{layout}'" if layout}
235
235
  group by p.ID
236
236
  EOQ
@@ -240,7 +240,7 @@ module SuttyMigration
240
240
  # converted to arrays
241
241
  #
242
242
  # @return [String]
243
- def meta_query
243
+ def meta_query(layout: nil)
244
244
  <<~EOQ
245
245
  select
246
246
  post_id,
@@ -253,6 +253,7 @@ module SuttyMigration
253
253
  from #{prefix}postmeta
254
254
  group by post_id, meta_key
255
255
  )
256
+ #{"where post_id in (select ID from #{prefix}posts where post_type = '#{layout}')" if layout}
256
257
  group by post_id
257
258
  EOQ
258
259
  end
@@ -261,7 +262,7 @@ module SuttyMigration
261
262
  #
262
263
  # @param :layout [String] Layout name
263
264
  # @return [String]
264
- def terms_query
265
+ def terms_query(layout: nil)
265
266
  <<~EOQ
266
267
  select
267
268
  post_id,
@@ -274,7 +275,8 @@ module SuttyMigration
274
275
  from #{prefix}term_relationships as r
275
276
  left join #{prefix}term_taxonomy as tt on tt.term_taxonomy_id = r.term_taxonomy_id
276
277
  left join #{prefix}terms as t on t.term_id = tt.term_id
277
- group by r.object_id)
278
+ #{"where r.object_id in (select ID from #{prefix}posts where post_type = '#{layout}')" if layout}
279
+ group by r.object_id, tt.taxonomy)
278
280
  group by post_id
279
281
  EOQ
280
282
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sutty-migration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-31 00:00:00.000000000 Z
11
+ date: 2021-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll