diff --git a/deploy/setup.yml b/deploy/setup.yml index 83e92d4b..e4df1aab 100644 --- a/deploy/setup.yml +++ b/deploy/setup.yml @@ -442,13 +442,21 @@ mode: "755" state: directory - - name: Create 10min cron job to run `rails nc_mall:sync` + - name: Remove 10min cron job to run `rails nc_mall:sync` become_user: impress cron: + state: absent name: "Impress: sync NC Mall data" minute: "*/10" job: "bash -c 'source /etc/profile && source ~/.bash_profile && cd /srv/impress/current && bin/rails nc_mall:sync'" + - name: Create 10min cron job to run `rails neopets:import:nc_mall` + become_user: impress + cron: + name: "Impress: import NC Mall data" + minute: "*/10" + job: "bash -c 'source /etc/profile && source ~/.bash_profile && cd /srv/impress/current && bin/rails neopets:import:nc_mall'" + - name: Create weekly cron job to run `rails public_data:commit` become_user: impress cron: diff --git a/lib/tasks/neopets/import.rake b/lib/tasks/neopets/import.rake new file mode 100644 index 00000000..6c6ecbbd --- /dev/null +++ b/lib/tasks/neopets/import.rake @@ -0,0 +1,7 @@ +namespace :neopets do + task :import => [ + "neopets:import:nc_mall", + "neopets:import:rainbow_pool", + "neopets:import:styling_studio", + ] +end diff --git a/lib/tasks/nc_mall.rake b/lib/tasks/neopets/import/nc_mall.rake similarity index 97% rename from lib/tasks/nc_mall.rake rename to lib/tasks/neopets/import/nc_mall.rake index 3a90cbeb..fb110714 100644 --- a/lib/tasks/nc_mall.rake +++ b/lib/tasks/neopets/import/nc_mall.rake @@ -1,9 +1,11 @@ -namespace :nc_mall do +namespace "neopets:import" do desc "Sync our NCMallRecord table with the live NC Mall" - task :sync => :environment do + task :nc_mall => :environment do # Log to STDOUT. Rails.logger = Logger.new(STDOUT) + puts "Importing from NC Mall…" + # First, load all records of what's being sold in the live NC Mall. We load # the homepage and all pages linked from the main document, and extract the # items from each. (We also de-duplicate the items, which is important diff --git a/lib/tasks/rainbow_pool.rake b/lib/tasks/neopets/import/rainbow_pool.rake similarity index 96% rename from lib/tasks/rainbow_pool.rake rename to lib/tasks/neopets/import/rainbow_pool.rake index 37d30a01..d0910bc9 100644 --- a/lib/tasks/rainbow_pool.rake +++ b/lib/tasks/neopets/import/rainbow_pool.rake @@ -1,11 +1,13 @@ require "addressable/template" require "async/http/internet/instance" -namespace :rainbow_pool do +namespace "neopets:import" do desc "Import all basic image hashes from the Rainbow Pool, onto PetTypes" - task :import => :environment do + task :rainbow_pool => :environment do neologin = STDIN.getpass("Neologin cookie: ") + puts "Importing from Rainbow Pool…" + all_pet_types = PetType.all.to_a all_pet_types_by_species_id_and_color_id = all_pet_types. to_h { |pt| [[pt.species_id, pt.color_id], pt] } diff --git a/lib/tasks/alt_styles.rake b/lib/tasks/neopets/import/styling_studio.rake similarity index 93% rename from lib/tasks/alt_styles.rake rename to lib/tasks/neopets/import/styling_studio.rake index f4f75f5a..37e7f2c5 100644 --- a/lib/tasks/alt_styles.rake +++ b/lib/tasks/neopets/import/styling_studio.rake @@ -1,8 +1,10 @@ -namespace :alt_styles do - desc "Import alt style info from the NC Mall" - task :import => :environment do +namespace "neopets:import" do + desc "Import alt style info from the NC Styling Studio" + task :styling_studio => :environment do neologin = STDIN.getpass("Neologin cookie: ") + puts "Importing from Styling Studio…" + all_species = Species.order(:name).to_a # Load 10 species pages from the NC Mall at a time.