Merge pull request #46 from jedmund/job-icons

Adds support for Granblue IDs on Jobs
This commit is contained in:
Justin Edmund 2023-01-22 23:15:39 -08:00 committed by GitHub
commit a1967bbd2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 13 deletions

View file

@ -17,7 +17,7 @@ module Api
]
end
fields :row, :ml, :order
fields :granblue_id, :row, :ml, :order
end
end
end

View file

@ -0,0 +1,5 @@
class AddGranblueIdToJobs < ActiveRecord::Migration[7.0]
def change
add_column :jobs, :granblue_id, :string
end
end

View file

@ -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|

View file

@ -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

33
lib/tasks/export_job.rake Normal file
View file

@ -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