Compare commits
3 commits
main
...
jedmund/as
| Author | SHA1 | Date | |
|---|---|---|---|
| 6fba4772c5 | |||
| 2a48bf94f4 | |||
| aee9e48a69 |
5 changed files with 89 additions and 14 deletions
|
|
@ -10,6 +10,10 @@ module Api
|
||||||
render json: JobBlueprint.render(Job.all)
|
render json: JobBlueprint.render(Job.all)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
render json: JobBlueprint.render(Job.find_by(granblue_id: params[:id]))
|
||||||
|
end
|
||||||
|
|
||||||
def update_job
|
def update_job
|
||||||
if job_params[:job_id] != -1
|
if job_params[:job_id] != -1
|
||||||
# Extract job and find its main skills
|
# Extract job and find its main skills
|
||||||
|
|
@ -30,10 +34,10 @@ module Api
|
||||||
|
|
||||||
# Remove extra subskills if necessary
|
# Remove extra subskills if necessary
|
||||||
if old_job &&
|
if old_job &&
|
||||||
%w[1 2 3].include?(old_job.row) &&
|
%w[1 2 3].include?(old_job.row) &&
|
||||||
%w[4 5 ex2].include?(job.row) &&
|
%w[4 5 ex2].include?(job.row) &&
|
||||||
@party.skill1 && @party.skill2 && @party.skill3 &&
|
@party.skill1 && @party.skill2 && @party.skill3 &&
|
||||||
@party.skill1.sub && @party.skill2.sub && @party.skill3.sub
|
@party.skill1.sub && @party.skill2.sub && @party.skill3.sub
|
||||||
@party['skill3_id'] = nil
|
@party['skill3_id'] = nil
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
@ -64,7 +68,8 @@ module Api
|
||||||
new_skill_ids = new_skill_keys.map { |key| job_params[key] }
|
new_skill_ids = new_skill_keys.map { |key| job_params[key] }
|
||||||
new_skill_ids.map do |id|
|
new_skill_ids.map do |id|
|
||||||
skill = JobSkill.find(id)
|
skill = JobSkill.find(id)
|
||||||
raise Api::V1::IncompatibleSkillError.new(job: @party.job, skill: skill) if mismatched_skill(@party.job, skill)
|
raise Api::V1::IncompatibleSkillError.new(job: @party.job, skill: skill) if mismatched_skill(@party.job,
|
||||||
|
skill)
|
||||||
end
|
end
|
||||||
|
|
||||||
positions = extract_positions_from_keys(new_skill_keys)
|
positions = extract_positions_from_keys(new_skill_keys)
|
||||||
|
|
@ -162,8 +167,8 @@ module Api
|
||||||
if %w[4 5 ex2].include?(job.row)
|
if %w[4 5 ex2].include?(job.row)
|
||||||
if skill.base && !mismatched_base
|
if skill.base && !mismatched_base
|
||||||
false
|
false
|
||||||
else
|
elsif mismatched_emp || mismatched_main
|
||||||
true if mismatched_emp || mismatched_main
|
true
|
||||||
end
|
end
|
||||||
elsif mismatched_emp || mismatched_main
|
elsif mismatched_emp || mismatched_main
|
||||||
true
|
true
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
require "active_support/core_ext/integer/time"
|
require 'active_support/core_ext/integer/time'
|
||||||
|
|
||||||
Rails.application.configure do
|
Rails.application.configure do
|
||||||
# Settings specified here will take precedence over those in config/application.rb.
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
config.hosts << "staging-api.granblue.team"
|
config.hosts << 'staging-api.granblue.team'
|
||||||
|
|
||||||
# In the development environment your application's code is reloaded any time
|
# In the development environment your application's code is reloaded any time
|
||||||
# it changes. This slows down response time but is perfect for development
|
# it changes. This slows down response time but is perfect for development
|
||||||
|
|
@ -20,10 +20,10 @@ Rails.application.configure do
|
||||||
|
|
||||||
# Enable/disable caching. By default caching is disabled.
|
# Enable/disable caching. By default caching is disabled.
|
||||||
# Run rails dev:cache to toggle caching.
|
# Run rails dev:cache to toggle caching.
|
||||||
if Rails.root.join("tmp/caching-dev.txt").exist?
|
if Rails.root.join('tmp/caching-dev.txt').exist?
|
||||||
config.cache_store = :memory_store
|
config.cache_store = :memory_store
|
||||||
config.public_file_server.headers = {
|
config.public_file_server.headers = {
|
||||||
"Cache-Control" => "public, max-age=#{2.days.to_i}"
|
'Cache-Control' => "public, max-age=#{2.days.to_i}"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
config.action_controller.perform_caching = false
|
config.action_controller.perform_caching = false
|
||||||
|
|
@ -57,4 +57,23 @@ Rails.application.configure do
|
||||||
|
|
||||||
# Uncomment if you wish to allow Action Cable access from any origin.
|
# Uncomment if you wish to allow Action Cable access from any origin.
|
||||||
# config.action_cable.disable_request_forgery_protection = true
|
# config.action_cable.disable_request_forgery_protection = true
|
||||||
|
#
|
||||||
|
|
||||||
|
logger = ActiveSupport::Logger.new(STDOUT)
|
||||||
|
# To support a formatter, you must manually assign a formatter from the config.log_formatter value to the logger.
|
||||||
|
logger.formatter = config.log_formatter
|
||||||
|
# config.logger is the logger that will be used for Rails.logger and any
|
||||||
|
# related Rails logging such as ActiveRecord::Base.logger.
|
||||||
|
# It defaults to an instance of ActiveSupport::TaggedLogging that wraps an
|
||||||
|
# instance of ActiveSupport::Logger which outputs a log to the log/ directory.
|
||||||
|
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
||||||
|
# config.log_level defines the verbosity of the Rails logger.
|
||||||
|
# This option defaults to :debug for all environments.
|
||||||
|
# The available log levels are: :debug, :info, :warn, :error, :fatal, and :unknown
|
||||||
|
# config.log_level = :debug
|
||||||
|
# config.log_tags accepts a list of: methods that the request object responds to,
|
||||||
|
# a Proc that accepts the request object, or something that responds to to_s.
|
||||||
|
# This makes it easy to tag log lines with debug information like subdomain and request id -
|
||||||
|
# both very helpful in debugging multi-user production applications.
|
||||||
|
config.log_tags = [:request_id]
|
||||||
end
|
end
|
||||||
|
|
|
||||||
12
config/initializers/active_record_logger.rb
Normal file
12
config/initializers/active_record_logger.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class CacheFreeLogger < ActiveSupport::Logger
|
||||||
|
def add(severity, message = nil, progname = nil, &block)
|
||||||
|
return true if progname&.include? 'CACHE'
|
||||||
|
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ActiveRecord::Base.logger = CacheFreeLogger.new($stdout)
|
||||||
|
ActiveRecord::Base.logger.level = 1
|
||||||
|
|
@ -41,6 +41,7 @@ Rails.application.routes.draw do
|
||||||
get 'jobs', to: 'jobs#all'
|
get 'jobs', to: 'jobs#all'
|
||||||
|
|
||||||
get 'jobs/skills', to: 'job_skills#all'
|
get 'jobs/skills', to: 'job_skills#all'
|
||||||
|
get 'jobs/:id', to: 'jobs#show'
|
||||||
get 'jobs/:id/skills', to: 'job_skills#job'
|
get 'jobs/:id/skills', to: 'job_skills#job'
|
||||||
get 'jobs/:id/accessories', to: 'job_accessories#job'
|
get 'jobs/:id/accessories', to: 'job_accessories#job'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,15 @@ namespace :granblue do
|
||||||
puts "\t404 returned\t#{url}"
|
puts "\t404 returned\t#{url}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def download_elemental_images(url, size, path, filename)
|
||||||
|
filepath = "#{path}/#{filename}"
|
||||||
|
download = URI.parse(url).open
|
||||||
|
puts "\tDownloading #{size}\t#{url}..."
|
||||||
|
IO.copy_stream(download, filepath)
|
||||||
|
rescue OpenURI::HTTPError
|
||||||
|
puts "\t404 returned\t#{url}"
|
||||||
|
end
|
||||||
|
|
||||||
def download_chara_images(id)
|
def download_chara_images(id)
|
||||||
sizes = %w[main grid square]
|
sizes = %w[main grid square]
|
||||||
|
|
||||||
|
|
@ -109,13 +118,42 @@ namespace :granblue do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc 'Downloads elemental weapon images'
|
||||||
|
task :download_elemental_images, [:id_base] => :environment do |_t, args|
|
||||||
|
id_base = args[:id_base].to_i
|
||||||
|
suffixes = [2, 3, 4, 1, 6, 5]
|
||||||
|
|
||||||
|
(1..6).each do |i|
|
||||||
|
id = id_base + (i - 1) * 100
|
||||||
|
|
||||||
|
sizes = %w[main grid square]
|
||||||
|
|
||||||
|
url = {
|
||||||
|
'main': build_weapon_url(id, 'main'),
|
||||||
|
'grid': build_weapon_url(id, 'grid'),
|
||||||
|
'square': build_weapon_url(id, 'square')
|
||||||
|
}
|
||||||
|
|
||||||
|
puts "Elemental Weapon #{id}_#{suffixes[i - 1]}"
|
||||||
|
sizes.each do |size|
|
||||||
|
path = "#{Rails.root}/download/weapon-#{size}"
|
||||||
|
filename = "#{id}_#{suffixes[i - 1]}.jpg"
|
||||||
|
download_elemental_images(url[size.to_sym], size, path, filename)
|
||||||
|
end
|
||||||
|
|
||||||
|
_progress_reporter(count: i, total: 6, result: "Elemental Weapon #{id}_#{suffixes[i - 1]}", bar_len: 40,
|
||||||
|
multi: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
desc 'Downloads images for the given Granblue_IDs'
|
desc 'Downloads images for the given Granblue_IDs'
|
||||||
task :download_images, %i[object] => :environment do |_t, args|
|
task :download_images, %i[object] => :environment do |_t, args|
|
||||||
object = args[:object]
|
object = args[:object]
|
||||||
list = args.extras
|
list = args.extras
|
||||||
|
|
||||||
list.each do |id|
|
list.each do |id|
|
||||||
if object == 'character'
|
case object
|
||||||
|
when 'character'
|
||||||
character = Character.find_by(granblue_id: id)
|
character = Character.find_by(granblue_id: id)
|
||||||
next unless character
|
next unless character
|
||||||
|
|
||||||
|
|
@ -123,7 +161,7 @@ namespace :granblue do
|
||||||
download_chara_images("#{id}_02")
|
download_chara_images("#{id}_02")
|
||||||
download_chara_images("#{id}_03") if character.flb
|
download_chara_images("#{id}_03") if character.flb
|
||||||
download_chara_images("#{id}_04") if character.ulb
|
download_chara_images("#{id}_04") if character.ulb
|
||||||
elsif object == 'weapon'
|
when 'weapon'
|
||||||
weapon = Weapon.find_by(granblue_id: id)
|
weapon = Weapon.find_by(granblue_id: id)
|
||||||
next unless weapon
|
next unless weapon
|
||||||
|
|
||||||
|
|
@ -133,7 +171,7 @@ namespace :granblue do
|
||||||
download_weapon_images("#{id}_02")
|
download_weapon_images("#{id}_02")
|
||||||
download_weapon_images("#{id}_03")
|
download_weapon_images("#{id}_03")
|
||||||
end
|
end
|
||||||
elsif object == 'summon'
|
when 'summon'
|
||||||
summon = Summon.find_by(granblue_id: id)
|
summon = Summon.find_by(granblue_id: id)
|
||||||
next unless summon
|
next unless summon
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue