Compare commits

..

No commits in common. "ec0b8d9cb9494e9b11f4d745287af541497def1f" and "1d1dc1532079533b2ef2e90f721a622960033895" have entirely different histories.

5 changed files with 12 additions and 53 deletions

View file

@ -442,21 +442,13 @@
mode: "755"
state: directory
- name: Remove 10min cron job to run `rails nc_mall:sync`
- name: Create 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:

View file

@ -1,7 +1,7 @@
namespace "neopets:import" do
desc "Import alt style info from the NC Styling Studio"
task :styling_studio => ["neopets:import:neologin", :environment] do
puts "Importing from Styling Studio…"
namespace :alt_styles do
desc "Import alt style info from the NC Mall"
task :import => :environment do
neologin = STDIN.getpass("Neologin cookie: ")
all_species = Species.order(:name).to_a
@ -19,7 +19,7 @@ namespace "neopets:import" do
begin
styles_by_species_id[species.id] = Neopets::NCMall.load_styles(
species_id: species.id,
neologin: Neologin.cookie,
neologin:,
)
rescue => error
puts "\n⚠️ Error loading for #{species.human_name}, skipping: #{error.message}"

View file

@ -1,11 +1,9 @@
namespace "neopets:import" do
namespace :nc_mall do
desc "Sync our NCMallRecord table with the live NC Mall"
task :nc_mall => :environment do
task :sync => :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

View file

@ -1,31 +0,0 @@
module Neologin
def self.cookie
raise "must run neopets:import:neologin first" if @cookie.nil?
@cookie
end
def self.cookie?
@cookie.present?
end
def self.cookie=(new_cookie)
@cookie = new_cookie
end
end
namespace :neopets do
task :import => [
"neopets:import:neologin",
"neopets:import:nc_mall",
"neopets:import:rainbow_pool",
"neopets:import:styling_studio",
]
namespace :import do
task :neologin do
unless Neologin.cookie?
Neologin.cookie = STDIN.getpass("Neologin cookie: ")
end
end
end
end

View file

@ -1,10 +1,10 @@
require "addressable/template"
require "async/http/internet/instance"
namespace "neopets:import" do
namespace :rainbow_pool do
desc "Import all basic image hashes from the Rainbow Pool, onto PetTypes"
task :rainbow_pool => ["neopets:import:neologin", :environment] do
puts "Importing from Rainbow Pool…"
task :import => :environment do
neologin = STDIN.getpass("Neologin cookie: ")
all_pet_types = PetType.all.to_a
all_pet_types_by_species_id_and_color_id = all_pet_types.
@ -16,7 +16,7 @@ namespace "neopets:import" do
Species.order(:name).each do |species|
begin
hashes_by_color_name = RainbowPool.load_hashes_for_species(
species.id, Neologin.cookie)
species.id, neologin)
rescue => error
puts "Failed to load #{species.name} page, skipping: #{error.message}"
next