contentful-scheduler-custom 1.6.7.5305 → 1.6.7.5306

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: d8ff70183a47c8a325241ce6485021a62463f6f7f925c364faf3f583fdf6760e
4
- data.tar.gz: 96ad1987ddee6a56d2f57777c11407985c3587aa1e7ecea00820eb5affbd7340
3
+ metadata.gz: 700551e41c83f6056ffda53598bf8841d577f5dc48e25c0e9bddc2c2b9418aa6
4
+ data.tar.gz: 92fc0df6e2d02eaadc9e6e3b48acff59a3309d2c030d739401f878073d8e363e
5
5
  SHA512:
6
- metadata.gz: 6c3ce2680b11690215d1a25a6352c2f0bbeb98d3dc7d481349b284bb8cdb0b5b6690a18f01bc8a0fddcd426fe3d0f66cfd41e009b75e044cbf282762d18315a1
7
- data.tar.gz: 043b98d34c58241cf07321980e2a437801bc9a9bfff0269b7d0b28589b08b48e2c469e3165ad9ac45b9e8941e9b1fdbd00586f59f0e1e24ffbf962150a28a35d
6
+ metadata.gz: fff0cc3a64d86c88f4014537316523837e969b7572c75ba69ca0437c811f002920853bec23d5ecbdbd22787f4a03ee5a91c69ce5d72379af14e9fbb30be1ed0e
7
+ data.tar.gz: 783ecd869f540f40ae6936f03a544dff803d35a51ea43f6e36cf3825eaf6efed54ecdeb73ea48ff23b4fa516f5bbf5b3ff80bf0f263b9944c3c58aa3582dbc9e
@@ -9,21 +9,6 @@ module Contentful
9
9
  class Publish
10
10
  @queue = :publish
11
11
 
12
- def recursive_flatten(array, results = [])
13
- array.each do |element|
14
- if element.class == Array
15
- recursive_flatten(element, results)
16
- else
17
- results << element
18
- end
19
- end
20
- results
21
- end
22
-
23
- def all_keys(hash)
24
- hash.flat_map { |k, v| [k] + (v.is_a?(Hash) ? all_keys(v) : [v]) }
25
- end
26
-
27
12
  def self.perform(space_id, entry_id, token)
28
13
  logger = Logger.new(STDOUT)
29
14
  client1 = Contentful::Client.new(
@@ -44,9 +29,16 @@ module Contentful
44
29
 
45
30
  if !linked_enteries.raw["includes"].nil? && !linked_enteries.raw["includes"]["Entry"].nil?
46
31
  logger.info "CHuby raw element is ==> #{linked_enteries.raw["includes"]["Entry"]}"
32
+ linkedEnteriesId = extract_element_ids(linked_enteries.raw["includes"]["Entry"])
33
+ linkedEnteriesId.each do |id|
34
+ client.entries.find(space_id, id).publish
35
+ end
47
36
  end
48
37
 
49
38
 
39
+
40
+
41
+ =begin
50
42
  linked_enteries.each do |entry|
51
43
  logger.info "Enteries are ===>>>> #{entry.raw}"
52
44
  end
@@ -67,10 +59,35 @@ module Contentful
67
59
  end
68
60
  end
69
61
  end
62
+ =end
70
63
 
71
64
  client.entries.find(space_id, entry_id).publish
72
65
  end
73
66
 
67
+
68
+ def extract_element_ids(input_array)
69
+ ids = []
70
+ input_array.each {|item| (ids << (get_each_field item)).flatten!}
71
+ ids.uniq
72
+ end
73
+
74
+ def get_each_field(item)
75
+ ids = []
76
+ keys = item["fields"].keys
77
+ keys.each {|key| (ids << (get_each_element key, item["fields"])).flatten!}
78
+ return ids
79
+ end
80
+
81
+ def get_each_element(key, item)
82
+ ids = []
83
+ if item[key].kind_of?(Array)
84
+ item[key].each {|i| (!(i["sys"]["linkType"].nil?) && i["sys"]["linkType"] == "Entry") ? ids.push(i["sys"]["id"]) : nil}
85
+ elsif item[key].kind_of?(Hash)
86
+ (!( item[key]["sys"]["linkType"].nil? ) && item[key]["sys"]["linkType"] == "Entry") ? ids.push(item[key]["sys"]["id"]) : nil
87
+ end
88
+ return ids
89
+ end
90
+
74
91
  end
75
92
  end
76
93
  end
@@ -1,5 +1,5 @@
1
1
  module Contentful
2
2
  module Scheduler
3
- VERSION = "1.6.7.5305"
3
+ VERSION = "1.6.7.5306"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentful-scheduler-custom
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.7.5305
4
+ version: 1.6.7.5306
5
5
  platform: ruby
6
6
  authors:
7
7
  - Contentful GmbH (David Litvak Bruno0
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-19 00:00:00.000000000 Z
11
+ date: 2019-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contentful