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
require 'socket' | |
require 'singleton' | |
require 'stringio' | |
# A small persistence library that, at the moment, only | |
# implements an in-memory persistence strategy for getting | |
# and setting key-value pairs | |
module Persistence | |
module_function |
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
# Fit this into a translation layer...class? | |
# Should be able to return only a segment of the plan design | |
# If time and energy allows benchmark it, see if there are any obvious hotspots | |
module ProductResponse | |
module Serialized | |
Benefit = Struct.new(:plan_design_attribute_id, :tier_group_id, :vals, keyword_init: true) do | |
class << self | |
def build_from_plan_design_value(pdv) | |
new(vals: [], **pdv.attributes.symbolize_keys.slice(:plan_design_attribute_id, :tier_group_id)) |
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
require 'json' | |
staging_vars_hash = JSON.parse(`heroku config --app=feature-staging-app --json`) | |
vars_to_copy_hash = staging_vars_hash.reject { |k,_| k.match(/\AHEROKU/) } | |
vars_string = vars_to_copy_hash.to_a.map { |k_v_array| k, v = *k_v_array; "#{k}='#{v}'" }.join(" ") | |
`heroku config:set --app=feature-staging #{vars_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
desc "Resets feature-staging-app to mock production state" | |
task :reset do | |
system("heroku maintenance:on --app=feature-staging-app") | |
system("heroku run rails db:rollback STEP=2 --app=feature-staging-app") | |
system("git push feature-staging-app master") | |
system("heroku maintenance:off --app=feature-staging-app") | |
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
desc "Performs a dry run with elapsed time logging" | |
task :dry_run do | |
@time_summary = [] | |
with_timestamps("capturing backup of database", @time_summary) do | |
system("heroku pg:backups:capture --app=feature-staging-app") | |
end | |
with_timestamps("entering maintenance mode", @time_summary) do | |
system("heroku maintenance:on --app=feature-staging-app") |
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
heroku pg:backups:capture --app=production-app | |
heroku pg:backups --app=production-app | |
=== Backups | |
ID Created at Status Size Database | |
──── ───────────────────────── ─────────────────────────────────── ──────── ──────── | |
b001 2018-08-01 14:21:51 +0000 Completed 2018-08-01 14:22:09 +0000 1.62GB BLUE | |
heroku pg:backups:restore production-app::b001 --app=feature-staging-app |
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
require 'json' | |
staging_vars_hash = JSON.parse(`heroku config --app=feature-staging-app --json`) | |
vars_to_copy_hash = staging_vars_hash.reject { |k,_| k.match(/\AHEROKU/) } | |
vars_string = vars_to_copy_hash.to_a.map { |k_v_array| k, v = *k_v_array; "#{k}='#{v}'" }.join(" ") | |
`heroku config:set --app=feature-staging #{vars_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
desc 'identify routes defined by hashes that are not declared in routes.rb' | |
task :missing_routes => :environment do | |
file_paths = FileList[ | |
"#{Rails.root}/app/helpers/**/*.rb", | |
"#{Rails.root}/app/views/**/*.html.erb" | |
] | |
file_paths.each do |file_path| |