diff --git a/app/blueprints/api/v1/job_blueprint.rb b/app/blueprints/api/v1/job_blueprint.rb index 319a62b..43fabec 100644 --- a/app/blueprints/api/v1/job_blueprint.rb +++ b/app/blueprints/api/v1/job_blueprint.rb @@ -17,7 +17,7 @@ module Api ] end - fields :row, :ml, :order + fields :granblue_id, :row, :ml, :order end end end diff --git a/db/migrate/20230123055508_add_granblue_id_to_jobs.rb b/db/migrate/20230123055508_add_granblue_id_to_jobs.rb new file mode 100644 index 0000000..6cf8764 --- /dev/null +++ b/db/migrate/20230123055508_add_granblue_id_to_jobs.rb @@ -0,0 +1,5 @@ +class AddGranblueIdToJobs < ActiveRecord::Migration[7.0] + def change + add_column :jobs, :granblue_id, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 65680cb..41d51d3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 20_230_108_150_956) do +ActiveRecord::Schema[7.0].define(version: 2023_01_23_055508) do # These are extensions that must be enabled in order to support this database enable_extension 'btree_gin' enable_extension 'pg_trgm' @@ -128,16 +128,17 @@ ActiveRecord::Schema[7.0].define(version: 20_230_108_150_956) do t.index ['job_id'], name: 'index_job_skills_on_job_id' end - create_table 'jobs', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| - t.string 'name_en' - t.string 'name_jp' - t.integer 'proficiency1' - t.integer 'proficiency2' - t.string 'row' - t.boolean 'ml', default: false - t.integer 'order' - t.uuid 'base_job_id' - t.index ['base_job_id'], name: 'index_jobs_on_base_job_id' + create_table "jobs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.string "name_en" + t.string "name_jp" + t.integer "proficiency1" + t.integer "proficiency2" + t.string "row" + t.boolean "ml", default: false + t.integer "order" + t.uuid "base_job_id" + t.string "granblue_id" + t.index ["base_job_id"], name: "index_jobs_on_base_job_id" end create_table 'oauth_access_grants', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| diff --git a/lib/tasks/export_all.rake b/lib/tasks/export_all.rake index 80198be..1af2841 100644 --- a/lib/tasks/export_all.rake +++ b/lib/tasks/export_all.rake @@ -32,7 +32,11 @@ namespace :granblue do Rake::Task['granblue:export:summon'].invoke('square') Rake::Task['granblue:export:summon'].reenable - puts 'Exported 9 files' + # Run job tasks + Rake::Task['granblue:export:job'].invoke + Rake::Task['granblue:export:job'].reenable + + puts 'Exported 10 files' end end end diff --git a/lib/tasks/export_job.rake b/lib/tasks/export_job.rake new file mode 100644 index 0000000..87bdb4d --- /dev/null +++ b/lib/tasks/export_job.rake @@ -0,0 +1,33 @@ +namespace :granblue do + namespace :export do + def build_job_icon_url(id) + # Set up URL + base_url = 'https://prd-game-a-granbluefantasy.akamaized.net/assets_en/img/sp/ui/icon/job' + extension = '.png' + + "#{base_url}/#{id}#{extension}" + end + + desc 'Exports a list of weapon URLs for a given size' + task :job do |_t, _args| + # Include weapon model + Dir.glob("#{Rails.root}/app/models/job.rb").each { |file| require file } + + # Set up filepath + dir = "#{Rails.root}/export/" + filename = "#{dir}/job-icon.txt" + FileUtils.mkdir(dir) unless Dir.exist?(dir) + + # Write to file + File.open(filename, 'w') do |f| + Job.all.each do |w| + f.write("#{build_job_icon_url(w.granblue_id.to_s)} \n") + end + end + + # CLI output + count = `wc -l #{filename}`.split.first.to_i + puts "Wrote #{count} job URLs for icon size" + end + end +end