Skip to content

Commit

Permalink
Fix Good Job production issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hulloitskai committed Aug 11, 2024
1 parent bb55cf2 commit d38809b
Show file tree
Hide file tree
Showing 22 changed files with 265 additions and 64 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ gem "addressable", "~> 2.8"
gem "discard", "~> 1.2"

# Typecheck code at runtime
gem "sorbet-runtime", "~> 0.5.10950"
gem "sorbet-runtime"

# Use Enumerize to enumerate attributes
gem "enumerize", "~> 2.6"
Expand Down Expand Up @@ -194,7 +194,7 @@ group :development do
gem "debug", platforms: %i[mri mingw x64_mingw]

# Typecheck code
gem "sorbet", "0.5.10950", require: false
gem "sorbet", require: false
gem "spoom"
gem "tapioca", "~> 0.11.9", require: false

Expand Down
86 changes: 45 additions & 41 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ GEM
bootsnap (1.16.0)
msgpack (~> 1.2)
break (0.40.0)
builder (3.2.4)
builder (3.3.0)
bullet (7.0.7)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
Expand All @@ -136,7 +136,7 @@ GEM
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
coderay (1.1.3)
concurrent-ruby (1.2.2)
concurrent-ruby (1.3.4)
crass (1.0.6)
css_parser (1.16.0)
addressable
Expand Down Expand Up @@ -164,8 +164,8 @@ GEM
activemodel
enumerize (2.7.0)
activesupport (>= 3.2)
erubi (1.12.0)
et-orbi (1.2.7)
erubi (1.13.0)
et-orbi (1.2.11)
tzinfo
faraday (2.7.11)
base64
Expand All @@ -175,13 +175,13 @@ GEM
ffi (1.15.5)
friendly_id (5.5.0)
activerecord (>= 4.0.0)
fugit (1.8.1)
et-orbi (~> 1, >= 1.2.7)
fugit (1.11.0)
et-orbi (~> 1, >= 1.2.11)
raabro (~> 1.4)
geocoder (1.8.2)
globalid (1.2.1)
activesupport (>= 6.1)
good_job (3.19.1)
good_job (3.99.1)
activejob (>= 6.0.0)
activerecord (>= 6.0.0)
concurrent-ruby (>= 1.0.2)
Expand Down Expand Up @@ -212,7 +212,7 @@ GEM
http-accept (1.7.0)
http-cookie (1.0.5)
domain_name (~> 0.5)
i18n (1.14.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
icalendar (2.9.0)
ice_cube (~> 0.16)
Expand All @@ -235,7 +235,8 @@ GEM
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.21.3)
logger (1.6.0)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
Expand All @@ -249,13 +250,13 @@ GEM
rest-client (>= 2.0.0)
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
method_source (1.1.0)
mime-types (3.5.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2023.0808)
mini_magick (4.12.0)
mini_mime (1.1.5)
minitest (5.20.0)
minitest (5.24.1)
msgpack (1.7.2)
multi_json (1.15.0)
multi_xml (0.6.0)
Expand All @@ -271,9 +272,9 @@ GEM
net-protocol
netrc (0.11.0)
nio4r (2.5.9)
nokogiri (1.15.4-arm64-darwin)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
oauth2 (2.0.9)
faraday (>= 0.17.3, < 3.0)
Expand Down Expand Up @@ -317,6 +318,7 @@ GEM
net-smtp
premailer (~> 1.7, >= 1.7.9)
prettier_print (1.2.1)
prism (0.30.0)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
Expand All @@ -339,8 +341,8 @@ GEM
puma (6.3.1)
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.7.1)
rack (2.2.8)
racc (1.8.1)
rack (2.2.9)
rack-protection (3.1.0)
rack (~> 2.2, >= 2.2.4)
rack-proxy (0.7.7)
Expand Down Expand Up @@ -383,13 +385,15 @@ GEM
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rbi (0.1.1)
rbi (0.1.14)
prism (>= 0.18.0, < 1.0.0)
sorbet-runtime (>= 0.5.9204)
yarp (>= 0.11.0)
rbs (3.5.2)
logger
rdoc (6.5.0)
psych (>= 4.0.0)
regexp_parser (2.8.1)
Expand Down Expand Up @@ -438,11 +442,11 @@ GEM
rubocop (~> 1.35)
rubocop-sorbet (0.7.3)
rubocop (>= 0.90.0)
ruby-lsp (0.10.1)
ruby-lsp (0.17.12)
language_server-protocol (~> 3.17.0)
sorbet-runtime
syntax_tree (>= 6.1.1, < 7)
yarp (>= 0.11, < 0.12)
prism (>= 0.29.0, < 0.31)
rbs (>= 3, < 4)
sorbet-runtime (>= 0.5.10782)
ruby-next-core (0.15.3)
ruby-progressbar (1.13.0)
ruby-vips (2.1.4)
Expand Down Expand Up @@ -470,14 +474,14 @@ GEM
snaky_hash (2.0.1)
hashie
version_gem (~> 1.1, >= 1.1.1)
sorbet (0.5.10950)
sorbet-static (= 0.5.10950)
sorbet-runtime (0.5.10950)
sorbet-static (0.5.10950-universal-darwin-22)
sorbet-static (0.5.10950-x86_64-linux)
sorbet-static-and-runtime (0.5.10950)
sorbet (= 0.5.10950)
sorbet-runtime (= 0.5.10950)
sorbet (0.5.11518)
sorbet-static (= 0.5.11518)
sorbet-runtime (0.5.11518)
sorbet-static (0.5.11518-universal-darwin)
sorbet-static (0.5.11518-x86_64-linux)
sorbet-static-and-runtime (0.5.11518)
sorbet (= 0.5.11518)
sorbet-runtime (= 0.5.11518)
spoom (1.2.4)
erubi (>= 1.10.0)
sorbet-static-and-runtime (>= 0.5.10187)
Expand All @@ -497,16 +501,16 @@ GEM
strong_password (0.0.10)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
tapioca (0.11.9)
tapioca (0.11.17)
bundler (>= 2.2.25)
netrc (>= 0.11.0)
parallel (>= 1.21.0)
rbi (~> 0.1.0, >= 0.1.0)
sorbet-static-and-runtime (>= 0.5.10187)
rbi (>= 0.1.4, < 0.2)
sorbet-static-and-runtime (>= 0.5.10820)
spoom (~> 1.2.0, >= 1.2.0)
thor (>= 1.2.0)
yard-sorbet
thor (1.2.2)
thor (1.3.1)
timeout (0.4.0)
twilio-ruby (6.7.0)
faraday (>= 0.9, < 3.0)
Expand Down Expand Up @@ -546,14 +550,14 @@ GEM
xpath (3.2.0)
nokogiri (~> 1.8)
yard (0.9.34)
yard-sorbet (0.8.1)
sorbet-runtime (>= 0.5)
yard (>= 0.9)
yarp (0.11.0)
zeitwerk (2.6.11)
yard-sorbet (0.9.0)
sorbet-runtime
yard
zeitwerk (2.6.17)

PLATFORMS
arm64-darwin-22
arm64-darwin-23
x86_64-linux

DEPENDENCIES
Expand Down Expand Up @@ -632,8 +636,8 @@ DEPENDENCIES
sendgrid-ruby (~> 6.6)
sentry-rails (~> 5.9)
silencer (~> 2.0)
sorbet (= 0.5.10950)
sorbet-runtime (~> 0.5.10950)
sorbet
sorbet-runtime
spoom
spring
sprockets-rails (~> 3.4)
Expand Down
11 changes: 0 additions & 11 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ class ApplicationController < ActionController::Base
}.compact
end

# == Authentication
sig { returns(User) }
def current_user!
authenticate_user!
end

sig { override.returns(T.nilable(User)) }
def current_user
super
end

private

# == Helpers
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/calendars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CalendarsController < ApplicationController

# == Actions
def show
user = current_user!
user = authenticate_user!
respond_to do |format|
format.ics do
cal = Icalendar::Calendar.new
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ def show

# == Filter Handlers
def import_activities
Activity.import_for_user!(current_user!)
Activity.import_for_user!(authenticate_user!)
end
end
2 changes: 1 addition & 1 deletion app/controllers/mobile_subscribers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ def set_subscriber
end

def import_activities
Activity.import_for_user!(current_user!)
Activity.import_for_user!(authenticate_user!)
end
end
2 changes: 1 addition & 1 deletion app/graphql/concerns/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def system_user?
end

sig { returns(User) }
def current_user!
def authenticate_user!
active_user or raise GraphQL::ExecutionError, "Not authenticated."
end
end
2 changes: 1 addition & 1 deletion app/graphql/mutations/convert_google_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Payload < T::Struct
# == Resolver
sig { override.params(google_event_id: String).returns(Payload) }
def resolve(google_event_id:)
owner = current_user!
owner = authenticate_user!
event = owner.google_event!(google_event_id)
activity = Activity.from_google_event(event, owner:)
if activity.save
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/mutations/create_activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def resolve(
location: nil,
description: nil
)
owner = current_user!
owner = authenticate_user!
google_event = owner.create_google_event!(
title: [name, "[open]"].join(" "),
during: start..(start + duration_seconds),
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/mutations/create_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Payload < T::Struct
# == Resolver
sig { override.params(attributes: T.untyped).returns(Payload) }
def resolve(**attributes)
owner = current_user!
owner = authenticate_user!
group = owner.owned_groups.build(**attributes)
if group.save
Payload.new(group:)
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/mutations/join_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Payload < T::Struct
# == Resolver
sig { override.params(group: Group).returns(Payload) }
def resolve(group:)
member = current_user!
member = authenticate_user!
membership = group.memberships.build(member:)
if membership.save
Payload.new(membership:)
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/mutations/update_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Payload < T::Struct
# == Resolver
sig { override.params(attributes: T.untyped).returns(Payload) }
def resolve(**attributes)
user = current_user!
user = authenticate_user!
if user.update_without_password(**attributes)
Payload.new(user:)
else
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/google_event_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def duration_seconds

sig { returns(T::Boolean) }
def is_organized_by_viewer # rubocop:disable Naming/PredicateName
Activity.google_event_organized_by_user?(object, current_user!)
Activity.google_event_organized_by_user?(object, authenticate_user!)
end

sig { returns(T::Boolean) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# frozen_string_literal: true

class RecreateGoodJobCronIndexesWithConditional < ActiveRecord::Migration[7.0]
disable_ddl_transaction!

def change
reversible do |dir|
dir.up do
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at_cond)
add_index :good_jobs, [:cron_key, :created_at], where: "(cron_key IS NOT NULL)",
name: :index_good_jobs_on_cron_key_and_created_at_cond, algorithm: :concurrently
end
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at_cond)
add_index :good_jobs, [:cron_key, :cron_at], where: "(cron_key IS NOT NULL)", unique: true,
name: :index_good_jobs_on_cron_key_and_cron_at_cond, algorithm: :concurrently
end

if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at)
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_created_at
end
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at)
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_cron_at
end
end

dir.down do
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at)
add_index :good_jobs, [:cron_key, :created_at],
name: :index_good_jobs_on_cron_key_and_created_at, algorithm: :concurrently
end
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at)
add_index :good_jobs, [:cron_key, :cron_at], unique: true,
name: :index_good_jobs_on_cron_key_and_cron_at, algorithm: :concurrently
end

if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at_cond)
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_created_at_cond
end
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at_cond)
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_cron_at_cond
end
end
end
end
end
Loading

0 comments on commit d38809b

Please sign in to comment.