* Add table for data version and migrate * Modify migration and re-migrate * Create data_version.rb Adds a model for DataVersion * Add aws-sdk-s3 and create aws_service.rb AwsService handles streaming game image files from the Granblue Fantasy server to our S3 instance. * Add importers The Importer libraries take CSV data and import them into the database for each type. We currently support characters, summons and weapons. * Add downloaders Downloaders take Granblue IDs and download images for those items from the Granblue Fantasy server in all relevant sizes. Downloaders can download to disk or stream the file directly to S3. * Create data_importer.rb * Fetches a list of all CSV files present in the updates folder * Checks which have already been imported * Sends unimported data to the appropriate Importer to handle * Create download_manager.rb Creates an appropriate downloader for each Granblue ID it receives * Update download_images.rake Most of this task has been extracted into the Downloader libraries * Update import_data.rake * Create deploy.rake This task is to be run as a post-deploy script. It checks for new unimported data, imports it, then downloads the relevant images to S3 or local disk depending on the parameters provided. * Update credentials.yml.enc * Began working on a README and added example CSVs * Modify importer to handle updates This way we can also add FLBs and other uncaps easier. * Updates only require values that will change When updating a row, fields that don't have a provided value will not be changed * Rebuild search indices in post deploy * Clean up logs with LoggingHelper * More logging adjustments Trying to get a nice-looking output * Change some ASCII characters * Final ASCII changes * Fix issues with Summon and Weapon importers * Finish README for contributing
52 lines
1.3 KiB
Ruby
52 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative '../granblue/downloaders/base_downloader'
|
|
require_relative '../logging_helper'
|
|
|
|
namespace :deploy do
|
|
desc 'Post-deployment tasks: Import new data and download related images. Options: TEST=true for test mode, VERBOSE=true for verbose output, STORAGE=local|s3|both'
|
|
task post_deployment: :environment do
|
|
include LoggingHelper
|
|
|
|
Dir[Rails.root.join('lib', 'granblue', '**', '*.rb')].each { |file| require file }
|
|
|
|
# Ensure Rails environment is loaded
|
|
Rails.application.eager_load!
|
|
|
|
log_header('Starting post-deploy script...', '-', false)
|
|
print "\n"
|
|
|
|
# Parse and validate storage option
|
|
storage = (ENV['STORAGE'] || 'both').to_sym
|
|
unless [:local, :s3, :both].include?(storage)
|
|
puts 'Invalid STORAGE option. Must be one of: local, s3, both'
|
|
exit 1
|
|
end
|
|
|
|
options = {
|
|
test_mode: ENV['TEST'] == 'true',
|
|
verbose: ENV['VERBOSE'] == 'true',
|
|
storage: storage
|
|
}
|
|
|
|
print "Test mode:\t"
|
|
if options[:test_mode]
|
|
print "✅ Enabled\n"
|
|
else
|
|
print "❌ Disabled\n"
|
|
end
|
|
|
|
print "Verbose output:\t"
|
|
if options[:verbose]
|
|
print "✅ Enabled\n"
|
|
else
|
|
print "❌ Disabled\n"
|
|
end
|
|
|
|
puts "Storage mode:\t#{storage}"
|
|
|
|
# Execute the task
|
|
manager = PostDeploymentManager.new(options)
|
|
manager.run
|
|
end
|
|
end
|