rooftop-spektrix_sync 0.0.3 → 0.0.3.2

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
  SHA1:
3
- metadata.gz: 0c6ea7f937c20f6eeaefb7b45d6bd032002f63f1
4
- data.tar.gz: e8eac4c9b5e0be2a7292464f7b92328f6c03d25d
3
+ metadata.gz: d5a7934bd34481b83649a71e99d0a7e76371d34c
4
+ data.tar.gz: 8a896cb877434ea00994a55c19bc80858b417b82
5
5
  SHA512:
6
- metadata.gz: 363820205f2eb78e34c589ea37e01b763b03c44e1f62f92cd75a42582129f4daf10d07e1a1f4ff7f17b02d1b81d46114c88d64a22f468f6ffac85865224e797d
7
- data.tar.gz: 917bb08292a2ce12af2288c70f624a05c44ab25d0f3a2a3839d48e7c150b82afdec24e588249ee036b1562b8151a48ee390501a3ff7d24f50b7d45e6c5d4d425
6
+ metadata.gz: 55f9d502f3dc7e27f3695150b77ae29cdb5f45d1ee4150a06f03b6a0a41fe1bfff14cf113667137866c3a3931e3cd8ce0d84da1a2d4c49f95ed380aca3c9893e
7
+ data.tar.gz: 44840a229619f9ee869fb988c88ad3e2ebcac887000dc86147712b8a7e5d2dac437dd8338451c7f1ecd06b16bffd09275633bcf071e9ec22ad5253a44156bd7e
@@ -15,7 +15,7 @@ module Rooftop
15
15
  @rooftop_event = @rooftop_events.find {|e| e.meta_attributes[:spektrix_id].try(:to_i) == @spektrix_event.id.to_i}
16
16
  @rooftop_price_lists = sync_task.rooftop_price_lists
17
17
  @sync_task = sync_task
18
- @logger.info("Fetching all instance statuses for event")
18
+ @logger.info("[spektrix] Fetching all instance statuses for event")
19
19
  @spektrix_instance_statuses = Spektrix::Events::InstanceStatus.where(event_id: @spektrix_event.id, all: true).to_a
20
20
  end
21
21
 
@@ -34,7 +34,7 @@ module Rooftop
34
34
  })
35
35
  sync()
36
36
  rescue => e
37
- @logger.fatal(e.to_s)
37
+ @logger.fatal("[spektrix] #{e}")
38
38
  end
39
39
  end
40
40
 
@@ -60,12 +60,12 @@ module Rooftop
60
60
  end
61
61
 
62
62
  if @rooftop_event.save!
63
- @logger.info("#{new_event ? 'Created' : 'Saved'} event: #{rooftop_event_title} #{@rooftop_event.id}")
63
+ @logger.info("[spektrix] #{new_event ? 'Created' : 'Saved'} event: #{rooftop_event_title} #{@rooftop_event.id}")
64
64
  else
65
65
  sync_event_instances = false
66
66
  end
67
67
  else
68
- @logger.info("Skipping event update")
68
+ @logger.info("[spektrix] Skipping event update")
69
69
  end
70
70
 
71
71
  sync_instances if sync_event_instances
@@ -102,7 +102,7 @@ module Rooftop
102
102
  def sync_instances
103
103
  @rooftop_instances = @rooftop_event.instances.to_a
104
104
  @spektrix_instances = @spektrix_event.instances.to_a
105
- @logger.info("\tChecking #{@rooftop_instances.size} instances..")
105
+ @logger.info("[spektrix] Checking #{@rooftop_instances.size} instances..")
106
106
 
107
107
  synced_to_rooftop = [] # array of event instance id's that were updated/created on RT
108
108
 
@@ -113,21 +113,21 @@ module Rooftop
113
113
  delete_instances = @rooftop_instances.select{|i| delete_instance_ids.include?(i.meta_attributes[:spektrix_id])}
114
114
  # before we can call .destroy on an instance, we need to mutate the object so it has an :event_id to hit the proper destroy method endpoint...
115
115
  delete_instances.each do |instance|
116
- @logger.info("Deleting Rooftop Instance #{instance.id}")
116
+ @logger.info("[spektrix] Deleting Rooftop Instance #{instance.id}")
117
117
  instance.tap{|i| i.event_id = @rooftop_event.meta_attributes[:spektrix_id]}.destroy
118
118
  end
119
119
 
120
120
  @spektrix_instances.each_with_index do |instance, i|
121
- @logger.info("Instance #{instance.id}")
121
+ @logger.info("[spektrix] Instance #{instance.id}")
122
122
  begin
123
123
  tries ||= 2
124
124
  instance_sync = Rooftop::SpektrixSync::InstanceSync.new(instance, self)
125
125
  synced_to_rooftop << instance_sync.sync
126
126
  rescue => e
127
127
  if (tries -= 1).zero?
128
- @logger.fatal("Not retrying... #{e}")
128
+ @logger.fatal("[spektrix] Not retrying... #{e}")
129
129
  else
130
- @logger.warn("Retrying... #{e}")
130
+ @logger.warn("[spektrix] Retrying... #{e}")
131
131
  retry
132
132
  end
133
133
  end
@@ -141,7 +141,7 @@ module Rooftop
141
141
  end
142
142
 
143
143
  def update_event_metadata
144
- @logger.info("Saved event instances. Updating event metadata")
144
+ @logger.info("[spektrix] Saved event instances. Updating event metadata")
145
145
  Rooftop::Events::Event.post("#{@rooftop_event.class.collection_path}/#{@rooftop_event.id}/update_metadata")
146
146
  end
147
147
  end
@@ -20,7 +20,7 @@ module Rooftop
20
20
  end
21
21
  update_price
22
22
  if @rooftop_instance.price_list_id.nil?
23
- @logger.error("No price list for Spektrix instance id #{@spektrix_instance.id}")
23
+ @logger.error("[spektrix] No price list for Spektrix instance id #{@spektrix_instance.id}")
24
24
  return
25
25
  end
26
26
  update_meta_attributes
@@ -31,13 +31,13 @@ module Rooftop
31
31
  @rooftop_instance.meta_attributes[:spektrix_hash] = generate_spektrix_hash(@spektrix_instance)
32
32
 
33
33
  if @rooftop_instance.save!
34
- @logger.info("#{instance_updated ? "Updated" : "Created"} Rooftop instance #{@rooftop_instance.id}")
34
+ @logger.info("[spektrix] #{instance_updated ? "Updated" : "Created"} Rooftop instance #{@rooftop_instance.id}")
35
35
  return @rooftop_instance.id
36
36
  else
37
- @logger.info("\n\nCouldn't save instance\n\n")
37
+ @logger.error("[spektrix] Couldn't save Rooftop instance #{@rooftop_instance.id}")
38
38
  end
39
39
  else
40
- @logger.info("Skipping event instance save - computed hash matched")
40
+ @logger.info("[spektrix] Skipping event instance save - computed hash matched")
41
41
  return nil
42
42
  end
43
43
  end
@@ -23,11 +23,11 @@ module Rooftop
23
23
  @spektrix_price_lists.each do |spektrix_price_list|
24
24
  # Don't bother syncing a price list where none of the prices have bands.
25
25
  if spektrix_price_list.prices.nil?
26
- @logger.error("Spektrix price list ID #{spektrix_price_list.id} has no prices at all")
26
+ @logger.error("[spektrix] Spektrix price list ID #{spektrix_price_list.id} has no prices at all")
27
27
  next
28
28
  end
29
29
  if spektrix_price_list.prices.select {|p| !p.band.nil?}.empty?
30
- @logger.error("Spektrix price list ID #{spektrix_price_list.id} has prices with missing bands.")
30
+ @logger.error("[spektrix] Spektrix price list ID #{spektrix_price_list.id} has prices with missing bands.")
31
31
  end
32
32
 
33
33
  # find or create a price list
@@ -37,7 +37,7 @@ module Rooftop
37
37
  new_price_list = @rooftop_price_list.new?
38
38
  # save the price list to rooftop
39
39
  if @rooftop_price_list.save!
40
- @logger.info("#{new_price_list ? "Created" : "Updated"} price list #{spektrix_price_list.id}")
40
+ @logger.info("[spektrix] #{new_price_list ? "Created" : "Updated"} price list #{spektrix_price_list.id}")
41
41
  sync_prices(spektrix_price_list, @rooftop_price_list)
42
42
  end
43
43
  end
@@ -49,10 +49,10 @@ module Rooftop
49
49
  def sync_prices(spektrix_price_list, rooftop_price_list)
50
50
  # begin
51
51
  spektrix_price_list.prices.each_with_index do |spektrix_price, i |
52
- @logger.info("syncing price #{i+1} / #{spektrix_price_list.prices.count}")
52
+ @logger.info("[spektrix] syncing price #{i+1} / #{spektrix_price_list.prices.count}")
53
53
  # skip ones without a band
54
54
  if spektrix_price.band.nil?
55
- @logger.error("Spektrix price list ID: #{spektrix_price_list.id}: Price #{spektrix_price.price} with ticket type #{spektrix_price.ticket_type.name} does not have a band")
55
+ @logger.error("[spektrix] Spektrix price list ID: #{spektrix_price_list.id}: Price #{spektrix_price.price} with ticket type #{spektrix_price.ticket_type.name} does not have a band")
56
56
  next
57
57
  end
58
58
  current_rooftop_price = find_rooftop_price(rooftop_price_list, spektrix_price)
@@ -65,12 +65,12 @@ module Rooftop
65
65
  ticket_type_id = find_rooftop_ticket_type(spektrix_price).try(:id)
66
66
  price_band_id = find_rooftop_price_band(spektrix_price).try(:id)
67
67
  if ticket_type_id.nil?
68
- @logger.error("Ticket type for spektrix price #{spektrix_price.price} with ticket type #{spektrix_price.ticket_type.name} is nil")
68
+ @logger.error("[spektrix] Ticket type for spektrix price #{spektrix_price.price} with ticket type #{spektrix_price.ticket_type.name} is nil")
69
69
  next
70
70
  end
71
71
 
72
72
  if price_band_id.nil?
73
- @logger.error("Price band for spektrix price #{spektrix_price.price} with ticket type #{spektrix_price.ticket_type.name} is nil")
73
+ @logger.error("[spektrix] Price band for spektrix price #{spektrix_price.price} with ticket type #{spektrix_price.ticket_type.name} is nil")
74
74
  next
75
75
  end
76
76
 
@@ -83,7 +83,7 @@ module Rooftop
83
83
 
84
84
  new_price.title = "#{spektrix_price.band.name} (£#{new_price.meta_attributes[:ticket_price]})"
85
85
  if new_price.save!
86
- @logger.error("Spektrix price list ID: #{spektrix_price_list.id}: Saved price £#{new_price.meta_attributes[:ticket_price]} with ticket type #{spektrix_price.ticket_type.name} for price band #{spektrix_price.band.name}")
86
+ @logger.error("[spektrix] Spektrix price list ID: #{spektrix_price_list.id}: Saved price £#{new_price.meta_attributes[:ticket_price]} with ticket type #{spektrix_price.ticket_type.name} for price band #{spektrix_price.band.name}")
87
87
  end
88
88
  end
89
89
  # rescue => e
@@ -101,11 +101,11 @@ module Rooftop
101
101
  end
102
102
  Rooftop::Events::PriceList.where(post__in: rooftop_ids_to_remove).each do |pricelist|
103
103
  if pricelist.destroy
104
- @logger.info("Removed rooftop price list #{id} which didn't exist in spektrix")
104
+ @logger.info("[spektrix] Removed rooftop price list #{id} which didn't exist in spektrix")
105
105
  end
106
106
  end
107
107
  rescue => e
108
- @logger.fatal(e.to_s)
108
+ @logger.fatal("[spektrix] #{e}")
109
109
  end
110
110
  end
111
111
 
@@ -35,40 +35,38 @@ module Rooftop
35
35
  import_spektrix_description: true
36
36
  }
37
37
  @options = default_opts.merge!(opts)
38
- @logger.info("*************************************************************************")
39
- @logger.info("Running with options: #{@options.select {|k,v| k if v}.keys.join(", ")}")
40
- @logger.info("*************************************************************************")
38
+ @logger.info("[spektrix] Running with options: #{@options.select {|k,v| k if v}.keys.join("[spektrix] , ")}")
41
39
  rescue => e
42
- @logger.fatal("Couldn't start sync: #{e}")
40
+ @logger.fatal("[spektrix] Couldn't start sync: #{e}")
43
41
  end
44
42
  end
45
43
 
46
44
  def fetch_rooftop_and_spektrix_data
47
45
  @spektrix_events = @spektrix_events.present? ? @spektrix_events : Spektrix::Events::Event.all(instance_start_from: @starting_at.iso8601).to_a
48
46
  if @options[:spektrix_event_id]
49
- @logger.info("Selecting single Spektrix event")
47
+ @logger.info("[spektrix] Selecting single Spektrix event")
50
48
  @spektrix_events = @spektrix_events.select {|e| e.id == @options[:spektrix_event_id].to_s}
51
49
  else
52
- @logger.info("Fetching all Spektrix events")
50
+ @logger.info("[spektrix] Fetching all Spektrix events")
53
51
  end
54
52
 
55
- @logger.info("Fetching all Rooftop events")
53
+ @logger.info("[spektrix] Fetching all Rooftop events")
56
54
  @rooftop_events = Rooftop::Events::Event.all.to_a
57
55
  unless @options[:accept_empty_rooftop_events]
58
- @logger.info("No Rooftop events")
56
+ @logger.info("[spektrix] No Rooftop events")
59
57
  raise StandardError, "Rooftop returned an empty set of events which is probably wrong" if @rooftop_events.empty?
60
58
  end
61
- @logger.info("Fetching all Spektrix price lists")
59
+ @logger.info("[spektrix] Fetching all Spektrix price lists")
62
60
  @spektrix_price_lists = @spektrix_price_lists.present? ? @spektrix_price_lists : Spektrix::Tickets::PriceList.all.to_a
63
- @logger.info("Fetching all Rooftop Price lists")
61
+ @logger.info("[spektrix] Fetching all Rooftop Price lists")
64
62
  @rooftop_price_lists = Rooftop::Events::PriceList.all.to_a
65
63
 
66
64
  if @options[:import_price_bands] || @options[:import_ticket_types] || @options[:import_prices]
67
- @logger.info("Fetching all Spektrix price lists")
65
+ @logger.info("[spektrix] Fetching all Spektrix price lists")
68
66
  @spektrix_price_lists = @spektrix_price_lists.present? ? @spektrix_price_lists : Spektrix::Tickets::PriceList.all.to_a
69
- @logger.info("Fetching all Rooftop ticket types")
67
+ @logger.info("[spektrix] Fetching all Rooftop ticket types")
70
68
  @rooftop_ticket_types = Rooftop::Events::TicketType.all.to_a
71
- @logger.info("Fetching all Rooftop price bands")
69
+ @logger.info("[spektrix] Fetching all Rooftop price bands")
72
70
  @rooftop_price_bands = Rooftop::Events::PriceBand.all.to_a
73
71
  end
74
72
  end
@@ -138,7 +136,7 @@ module Rooftop
138
136
  # delete_orphan_spektrix_events
139
137
  # end
140
138
  rescue => e
141
- @logger.fatal(e)
139
+ @logger.fatal("[spektrix] #{e}")
142
140
  end
143
141
 
144
142
  end
@@ -149,15 +147,15 @@ module Rooftop
149
147
  begin
150
148
  tries ||= 2
151
149
  @spektrix_events.each_with_index do |event, i|
152
- @logger.info("Sync #{i+1} / #{@spektrix_events.length}: #{event.title}")
150
+ @logger.info("[spektrix] Sync #{i+1} / #{@spektrix_events.length}: #{event.title}")
153
151
  item = EventSync.new(event, self)
154
152
  item.sync_to_rooftop
155
153
  end
156
154
  rescue => e
157
155
  if (tries -= 1).zero?
158
- @logger.fatal("Not retrying...#{e.to_s}")
156
+ @logger.fatal("[spektrix] Not retrying...#{e.to_s}")
159
157
  else
160
- @logger.error("Retrying...#{e.to_s}")
158
+ @logger.error("[spektrix] Retrying...#{e.to_s}")
161
159
  retry
162
160
  end
163
161
  end
@@ -176,7 +174,7 @@ module Rooftop
176
174
  Rooftop::Events::Event.where(post__in: rooftop_ids_to_delete).each do |rooftop_event|
177
175
  title = rooftop_event.title
178
176
  if rooftop_event.destroy
179
- @logger.info("Removed Rooftop event #{title} which doesn't exist in Spektrix")
177
+ @logger.info("[spektrix] Removed Rooftop event #{title} which doesn't exist in Spektrix")
180
178
  end
181
179
  end
182
180
  end
@@ -187,7 +185,7 @@ module Rooftop
187
185
  spektrix_bands = Spektrix::Tickets::Band.all.to_a
188
186
  # create or update existing
189
187
  spektrix_bands.each do |band|
190
- @logger.info("Updating band #{band.name}")
188
+ @logger.info("[spektrix] Updating band #{band.name}")
191
189
  rooftop_band = rooftop_bands.find {|b| b.title == band.name} || Rooftop::Events::PriceBand.new
192
190
  rooftop_band.title = band.name
193
191
  rooftop_band.save!
@@ -200,7 +198,7 @@ module Rooftop
200
198
  rooftop_bands.find {|b| b.title == title}.destroy
201
199
  end
202
200
  rescue => e
203
- @logger.fatal(e.to_s)
201
+ @logger.fatal("[spektrix] #{e}")
204
202
  end
205
203
 
206
204
 
@@ -212,7 +210,7 @@ module Rooftop
212
210
  spektrix_ticket_types = Spektrix::Tickets::Type.all.to_a
213
211
  # create or update exiting
214
212
  spektrix_ticket_types.each do |type|
215
- @logger.info("Updating ticket type #{type.name}")
213
+ @logger.info("[spektrix] Updating ticket type #{type.name}")
216
214
  rooftop_ticket_type = rooftop_ticket_types.find {|t| t.title == type.name} || Rooftop::Events::TicketType.new
217
215
  rooftop_ticket_type.title = type.name
218
216
  rooftop_ticket_type.save!
@@ -225,7 +223,7 @@ module Rooftop
225
223
  rooftop_ticket_types.find {|b| b.title == title}.destroy
226
224
  end
227
225
  rescue => e
228
- @logger.fatal(e.to_s)
226
+ @logger.fatal("[spektrix] #{e}")
229
227
  end
230
228
  end
231
229
 
@@ -1,5 +1,5 @@
1
1
  module Rooftop
2
2
  module SpektrixSync
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.3.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rooftop-spektrix_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Jones