wdw_sources 0.1.5 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4afa0b0f0e23677d2be76840140678f0e53ce55576a7117a54490771e2260175
4
- data.tar.gz: dd7f862c2f326bba0a93d80b01d1506a93841a210ac69a648f496c4fdb867d17
3
+ metadata.gz: 14004ab8d7be10e8d895c57941f621ec13e5065f21fa5856b0efb66ea08f5d55
4
+ data.tar.gz: c1b39b314b6dbaf979057ed4b095565e96340a21c77fc225037ba8ffe1bed0e9
5
5
  SHA512:
6
- metadata.gz: b8d027d4e93702c33e9a22687a693780e2d89e17bee1fe35091d3e0325add9cc356301fb8aeeb09dacfd0c6bbc73fb4587780c9e1a62b9b238e7ff62b9f21fe0
7
- data.tar.gz: 2eed645636fc00d50636cbf5730eb2c63831e0f6aed758d1d7e6a2095dab2742b291a1297c27ca3511ad8c0a3a3c673299ef20ae5046b6aead9b98fce61151f4
6
+ metadata.gz: c2ca830f1282f12fd301cda9e8bc83ed443e0ca46c670326e1206c8ff60cce6e8308f6f23f762ed1309ab690b43eb4ef8206034e002bd71cad1ed8ac9e8c653b
7
+ data.tar.gz: 60df12c399f565fdea0c2c4d2c242178f2bd5acc389cc3d92cb29c0c07e33ff00b8fba5ae0ff85039def017356291678282295e60937a10f5d8304446c27d973
@@ -9,24 +9,40 @@ module WdwSources
9
9
  def self.sync_all(interest)
10
10
 
11
11
  tp_list = Touringplans.list_all(interest)
12
- tp_list.each do |tp_list_item|
13
- _cache_tp_place(tp_list_item, interest)
12
+ tp_list.each_with_index do |tp_list_item, index|
13
+ numerator = (index + 1).to_f
14
+ denominator = tp_list.length.to_f
15
+ percentage = (numerator / denominator * 100).round(2)
16
+
17
+ puts "#{tp_list_item.permalink} -- #{percentage}% of #{interest.to_s} synced"
18
+
19
+ tp_list_item_venue_permalink = tp_list_item.venue_permalink
20
+ tp_list_item_permalink = tp_list_item.permalink
21
+
22
+ _cache_tp_place(tp_list_item_venue_permalink, tp_list_item_permalink, interest)
14
23
  end
15
24
  end
16
25
 
17
- def self._cache_tp_place(tp_list_item, interest)
18
- interest = interest.to_sym
26
+ def self._cache_tp_place(tp_list_item_venue_permalink, tp_list_item_permalink, interest)
27
+ return "Missing tp_list_item_venue_permalink" if tp_list_item_venue_permalink.to_s.length < 3
28
+ return "Missing tp_list_item_permalink" if tp_list_item_permalink.to_s.length < 3
29
+ return "Missing interest" if interest.to_s.length < 3
19
30
 
20
- cache_resources = {attractions: WdwSources::TouringplansAttraction,
21
- dining: WdwSources::TouringplansDiningVenue,
22
- hotels: WdwSources::TouringplansHotel
31
+ cache_resources = {"attractions" => WdwSources::TouringplansAttraction,
32
+ "dining" => WdwSources::TouringplansDiningVenue,
33
+ "hotels" => WdwSources::TouringplansHotel
23
34
  }
24
35
 
25
36
  cache_resource = cache_resources[interest]
26
- cache_item = cache_resource.find_or_create_by(permalink: tp_list_item.permalink)
37
+ cache_item = cache_resource.find_or_create_by(permalink: tp_list_item_permalink)
38
+
39
+ tp_item_full_record = Touringplans.show(tp_list_item_venue_permalink,interest, tp_list_item_permalink)
27
40
 
28
- tp_item_full_record = Touringplans.show(tp_list_item.venue_permalink,interest, tp_list_item.permalink)
29
- cache_item.update!(tp_item_full_record.to_h)
41
+ vp = {venue_permalink: tp_list_item_venue_permalink}
42
+ full_record_hash = vp.merge(tp_item_full_record.to_h)
43
+ cache_item.update!(full_record_hash)
44
+ # tp_item_full_record.to_h
45
+ cache_item
30
46
  end
31
47
 
32
48
  # def self.cache_all_hotels
@@ -0,0 +1,5 @@
1
+ class AddThemeparksIdToWdwSourcesTouringplansAttractions < ActiveRecord::Migration[6.1]
2
+ def change
3
+ add_column :wdw_sources_touringplans_attractions, :themeparks_id, :text
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ # caches all of the hotels from touringplans.com
2
+ WdwSources::TouringplansUpdate.sync_all('hotels')
data/db/seeds.rb ADDED
@@ -0,0 +1,15 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7
+ # Character.create(name: 'Luke', movie: movies.first)
8
+ require_relative "../app/models/wdw_sources/touringplans_update.rb"
9
+ # cache data from touringplans.com
10
+ puts "syncing attractions".upcase
11
+ WdwSources::TouringplansUpdate.sync_all('attractions')
12
+ puts "syncing dining".upcase
13
+ WdwSources::TouringplansUpdate.sync_all('dining')
14
+ puts "syncing hotels".upcase
15
+ WdwSources::TouringplansUpdate.sync_all('hotels')
@@ -2,3 +2,23 @@
2
2
  # task :wdw_sources do
3
3
  # # Task goes here
4
4
  # end
5
+ namespace :db do
6
+ namespace :WdwSources do
7
+ desc "loads all seeds in db/seeds.rb"
8
+ task :seeds => :environment do
9
+ puts "Loading WdwSources db/seeds.rb"
10
+ WdwSources::Engine.load_seed
11
+ end
12
+
13
+ # namespace :seed do
14
+ # Dir[Rails.root.join('WdwSources', 'db', 'seeds', '*.rb')].each do |filename|
15
+ # task_name = File.basename(filename, '.rb')
16
+ # desc "Seed " task_name ", based on the file with the same name in `db/seeds/*.rb`"
17
+ # task task_name.to_sym => :environment do
18
+ # load(filename) if File.exist?(filename)
19
+ # end
20
+ # end
21
+ # end
22
+ end
23
+ end
24
+
@@ -1,3 +1,3 @@
1
1
  module WdwSources
2
- VERSION = '0.1.5'
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wdw_sources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - captproton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-26 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 6.1.4
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 6.1.4.1
19
+ version: 6.1.4
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: 6.1.4
30
24
  - - ">="
31
25
  - !ruby/object:Gem::Version
32
- version: 6.1.4.1
26
+ version: 6.1.4
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: touringplans
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -113,18 +107,21 @@ files:
113
107
  - db/migrate/20211024225255_create_wdw_sources_touringplans_dining_venues.rb
114
108
  - db/migrate/20211024225412_create_wdw_sources_touringplans_attractions.rb
115
109
  - db/migrate/20211024225455_create_wdw_sources_touringplans_hotels.rb
110
+ - db/migrate/20211111214149_add_themeparks_id_to_wdw_sources_touringplans_attractions.rb
111
+ - db/seeds.rb
112
+ - db/seeds/touringplans_hotels.rb
116
113
  - lib/generators/wdw_sources/install/install_generator.rb
117
114
  - lib/tasks/wdw_sources_tasks.rake
118
115
  - lib/wdw_sources.rb
119
116
  - lib/wdw_sources/engine.rb
120
117
  - lib/wdw_sources/version.rb
121
- homepage: https://github.com/wdwhub
118
+ homepage: https://github.com/wdwhub/wdw_sources
122
119
  licenses:
123
120
  - MIT
124
121
  metadata:
125
- homepage_uri: https://github.com/wdwhub
126
- source_code_uri: https://github.com/wdwhub
127
- changelog_uri: https://github.com/wdwhub
122
+ homepage_uri: https://github.com/wdwhub/wdw_sources
123
+ source_code_uri: https://github.com/wdwhub/wdw_sources
124
+ changelog_uri: https://github.com/wdwhub/wdw_sources
128
125
  post_install_message:
129
126
  rdoc_options: []
130
127
  require_paths: