This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enable sidekiq auto quit feature (Allows to enable/disable this feature) | |
# ENV['SIDEKIQ_QUIT_WHEN_EMPTY'] = true/false | |
# Apply manager patch | |
require_relative '../lib/sidekiq_manager_patch' | |
require 'sidekiq/manager' | |
Sidekiq::Manager.send :prepend, SidekiqManagerPatch | |
# Add auto quit middleware | |
require_relative '../lib/sidekiq_quit_when_empty' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module Storage | |
class RemoteFileRenamer < ApplicationService | |
attr_reader :file_blob, :new_name, :file | |
# @param file [ActiveStorage::File] | |
# @param new_name [String] | |
# @param variation [Symbol] Sample: :thumbnail | |
def initialize(file, new_name, variation = nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/activestorage.rb | |
# Ability to auto apply :default variant (if defined) before uploading original image | |
Rails.application.config.after_initialize do | |
ActiveStorage::Blob.class_eval do | |
alias_method :upload_without_unfurling_orig, :upload_without_unfurling | |
def upload_without_unfurling(io) | |
variant = attachments.first.send(:variants) | |
default_variant = variant[:default] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DelayedUploaderJob < ApplicationJob | |
queue_as :default | |
attr_reader :model, :attr_name | |
def perform(model_klass, id, attr_name) | |
@model = model_klass.constantize.find(id) | |
@attr_name = attr_name | |
upload_photo if tmp_file_data | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Schema Information | |
# | |
# Table name: photos | |
# | |
# id :integer not null, primary key | |
# position :integer | |
# created_at :datetime not null | |
# updated_at :datetime not null | |
class Photo < ApplicationRecord |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const fs = require('fs'); | |
const path = require('path'); | |
const esbuild = require('esbuild') | |
// Scan entrypoints | |
function scanFiles(dir, options = {}, result = []) { | |
let { recursive = false, ext = null } = options; | |
fs.readdirSync(dir).forEach(file => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#// .github/actions/ruby.yml => Google actions | |
# Note: Includes error silence to avoid invalid "exit 0" when opening cypress service (cypress bug) | |
- name: E2e tests | |
run: docker-compose run test_content_service bash -c "CI=true foreman start -f Procfile-test-e2e 2> /dev/null" | |
if: ${{env.FRONTEND_CHANGED}} | |
#// Procfile-e2e ==> Start all required services (rails, react app and then init cypress awaiting for react port) | |
test_api_server: rm -f tmp/pids/server-test.pid; bundle exec rails s -e test -p 3031 -b '0.0.0.0' --pid tmp/pids/server-test.pid | |
frontend: cd frontend/ && PORT=3030 BROWSER=none RAILS_PORT=3031 yarn start test --silent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Content System | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
- staging | |
pull_request: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repair_nested_params({id: '11', age: '25'}) # Sample | |
def repair_nested_params(obj) | |
obj.each { |key, value| obj[key] = parse_value(value) } | |
end | |
def parse_value(value) | |
return repair_nested_params(value) if value.is_a?(Hash) | |
return value.map(&method(:parse_value)) if value.is_a?(Array) | |
return value unless value.is_a?(String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# config/initializers/delayed_job_ext.rb | |
# unique jobs across workers | |
# Sample: my_model.delay(across_uniq_key: 'article-19').create | |
# Sample: my_model.delay(across_uniq_key: 'article-19').update | |
# Sample: my_model.delay(across_uniq_key: 'article-19').destroy | |
# ==> the jobs will be processed in serial, not in parallel: | |
# can not call update before create or run both at the same time | |
Delayed::Job.class_eval do |
NewerOlder