Syntax updates

This commit is contained in:
Justin Edmund 2025-01-08 12:12:56 -08:00
parent 53760bf87a
commit aee9e48a69
3 changed files with 47 additions and 11 deletions

View file

@ -10,6 +10,10 @@ module Api
render json: JobBlueprint.render(Job.all)
end
def show
render json: JobBlueprint.render(Job.find_by(granblue_id: params[:id]))
end
def update_job
if job_params[:job_id] != -1
# Extract job and find its main skills
@ -30,10 +34,10 @@ module Api
# Remove extra subskills if necessary
if old_job &&
%w[1 2 3].include?(old_job.row) &&
%w[4 5 ex2].include?(job.row) &&
@party.skill1 && @party.skill2 && @party.skill3 &&
@party.skill1.sub && @party.skill2.sub && @party.skill3.sub
%w[1 2 3].include?(old_job.row) &&
%w[4 5 ex2].include?(job.row) &&
@party.skill1 && @party.skill2 && @party.skill3 &&
@party.skill1.sub && @party.skill2.sub && @party.skill3.sub
@party['skill3_id'] = nil
end
else
@ -64,7 +68,8 @@ module Api
new_skill_ids = new_skill_keys.map { |key| job_params[key] }
new_skill_ids.map do |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
positions = extract_positions_from_keys(new_skill_keys)
@ -162,8 +167,8 @@ module Api
if %w[4 5 ex2].include?(job.row)
if skill.base && !mismatched_base
false
else
true if mismatched_emp || mismatched_main
elsif mismatched_emp || mismatched_main
true
end
elsif mismatched_emp || mismatched_main
true

View file

@ -1,8 +1,8 @@
require "active_support/core_ext/integer/time"
require 'active_support/core_ext/integer/time'
Rails.application.configure do
# 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
# 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.
# 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.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{2.days.to_i}"
'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
else
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.
# 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

View 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