Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/bundler/rubocop-rails-2.27.0
Browse files Browse the repository at this point in the history
  • Loading branch information
coalest authored Dec 20, 2024
2 parents 01e3818 + 8da1718 commit 59bd77a
Show file tree
Hide file tree
Showing 41 changed files with 512 additions and 156 deletions.
80 changes: 41 additions & 39 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ GEM
nokogiri (~> 1, >= 1.10.8)
base64 (0.2.0)
bcrypt (3.1.20)
benchmark (0.3.0)
benchmark (0.4.0)
better_errors (2.10.1)
erubi (>= 1.0.0)
rack (>= 0.9.0)
Expand Down Expand Up @@ -162,8 +162,8 @@ GEM
irb (~> 1.10)
reline (>= 0.3.8)
debug_inspector (1.2.0)
delayed_job (4.1.11)
activesupport (>= 3.0, < 8.0)
delayed_job (4.1.13)
activesupport (>= 3.0, < 9.0)
delayed_job_active_record (4.1.8)
activerecord (>= 3.0, < 8.0)
delayed_job (>= 3.0, < 5)
Expand Down Expand Up @@ -218,10 +218,10 @@ GEM
smart_properties
erubi (1.13.0)
execjs (2.10.0)
factory_bot (6.4.5)
factory_bot (6.5.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.4.3)
factory_bot (~> 6.4)
factory_bot_rails (6.4.4)
factory_bot (~> 6.5)
railties (>= 5.0.0)
faker (3.4.2)
i18n (>= 1.8.11, < 2)
Expand Down Expand Up @@ -314,14 +314,14 @@ GEM
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.7.2)
irb (1.14.1)
io-console (0.8.0)
irb (1.14.3)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jbuilder (2.13.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
json (2.7.5)
json (2.9.1)
jwt (2.9.1)
base64
kaminari (1.2.2)
Expand All @@ -348,7 +348,7 @@ GEM
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.1)
logger (1.6.3)
lograge (0.14.0)
actionpack (>= 4)
activesupport (>= 4)
Expand All @@ -373,7 +373,7 @@ GEM
method_source (1.1.0)
mini_magick (4.13.2)
mini_mime (1.1.5)
minitest (5.25.1)
minitest (5.25.4)
monetize (1.12.0)
money (~> 6.12)
money (6.16.0)
Expand Down Expand Up @@ -401,13 +401,13 @@ GEM
timeout
net-smtp (0.5.0)
net-protocol
newrelic_rpm (9.13.0)
newrelic_rpm (9.16.0)
nio4r (2.7.4)
nokogiri (1.16.7-arm64-darwin)
nokogiri (1.17.2-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-darwin)
nokogiri (1.17.2-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
nokogiri (1.17.2-x86_64-linux)
racc (~> 1.4)
notiffany (0.1.3)
nenv (~> 0.1)
Expand Down Expand Up @@ -442,7 +442,7 @@ GEM
activerecord (>= 6.1)
request_store (~> 1.4)
parallel (1.26.3)
parser (3.3.5.1)
parser (3.3.6.0)
ast (~> 2.4.1)
racc
pdf-core (0.9.0)
Expand Down Expand Up @@ -479,10 +479,11 @@ GEM
pry-stack_explorer (0.6.1)
binding_of_caller (~> 1.0)
pry (~> 0.13)
psych (5.1.2)
psych (5.2.2)
date
stringio
public_suffix (6.0.1)
puma (6.4.3)
puma (6.5.0)
nio4r (~> 2.0)
racc (1.8.1)
rack (3.1.8)
Expand Down Expand Up @@ -522,9 +523,9 @@ GEM
activesupport (>= 4.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.6.0)
rails-html-sanitizer (1.6.2)
loofah (~> 2.21)
nokogiri (~> 1.14)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (7.2.2)
actionpack (= 7.2.2)
activesupport (= 7.2.2)
Expand All @@ -538,15 +539,15 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdoc (6.7.0)
rdoc (6.10.0)
psych (>= 4.0.0)
recaptcha (5.17.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.22.2)
connection_pool
regexp_parser (2.9.2)
reline (0.5.10)
regexp_parser (2.9.3)
reline (0.6.0)
io-console (~> 0.5)
request_store (1.7.0)
rack (>= 1.4)
Expand Down Expand Up @@ -577,20 +578,19 @@ GEM
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.1)
rubocop (1.65.1)
rubocop (1.69.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.36.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.33.0)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.37.0)
parser (>= 3.3.1.0)
rubocop-performance (1.22.1)
rubocop-performance (1.23.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.27.0)
Expand Down Expand Up @@ -619,7 +619,7 @@ GEM
sprockets (> 3.0)
sprockets-rails
tilt
securerandom (0.3.1)
securerandom (0.4.1)
shellany (0.0.1)
shoulda-matchers (6.2.0)
activesupport (>= 5.2.0)
Expand Down Expand Up @@ -650,21 +650,21 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
standard (1.40.0)
standard (1.43.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.65.0)
rubocop (~> 1.69.1)
standard-custom (~> 1.0.0)
standard-performance (~> 1.4)
standard-performance (~> 1.6)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.5.0)
standard-performance (1.6.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.22.0)
rubocop-performance (~> 1.23.0)
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.1.1)
stringio (3.1.2)
strong_migrations (1.8.0)
activerecord (>= 5.2)
terser (1.2.4)
Expand All @@ -678,7 +678,9 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
unicode-display_width (3.1.2)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
uniform_notifier (1.16.0)
useragent (0.16.10)
version_gem (1.1.4)
Expand All @@ -693,7 +695,7 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.9.0)
webrick (1.9.1)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ class DashboardController < ApplicationController

def index
@org_stats = OrganizationStats.new(current_organization)
@total_inventory = current_organization.total_inventory
@partners_awaiting_review = current_organization.partners.awaiting_review
@outstanding_requests = current_organization.ordered_requests.where(status: %i[pending started]).order(:created_at)
@outstanding_requests = current_organization
.ordered_requests
.includes(:partner_user, :partner)
.where(status: %i[pending started])
.order(:created_at)
.limit(25)

@low_inventory_report = LowInventoryQuery.call(current_organization)

Expand Down
1 change: 1 addition & 0 deletions app/controllers/distributions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def update
@distribution.line_items.build if @distribution.line_items.size.zero?
@distribution.initialize_request_items
@items = current_organization.items.active.alphabetized
@partner_list = current_organization.partners.alphabetized
@storage_locations = current_organization.storage_locations.active_locations.alphabetized
render :edit
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/partners/family_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create
create_service = Partners::FamilyRequestCreateService.new(
partner_user_id: current_user.id,
family_requests_attributes: family_requests_attributes,
for_families: true
request_type: "child"
)

create_service.call
Expand All @@ -37,7 +37,7 @@ def validate
@partner_request = Partners::FamilyRequestCreateService.new(
partner_user_id: current_user.id,
family_requests_attributes: family_requests_attributes,
for_families: true
request_type: "child"
).initialize_only
if @partner_request.valid?
@total_items = @partner_request.total_items
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/partners/individuals_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def create
create_service = Partners::FamilyRequestCreateService.new(
partner_user_id: current_user.id,
comments: individuals_request_params[:comments],
family_requests_attributes: individuals_request_params[:items_attributes]&.values
family_requests_attributes: individuals_request_params[:items_attributes]&.values,
request_type: "individual"
)

create_service.call
Expand All @@ -36,7 +37,8 @@ def validate
@partner_request = Partners::FamilyRequestCreateService.new(
partner_user_id: current_user.id,
comments: individuals_request_params[:comments],
family_requests_attributes: individuals_request_params[:items_attributes]&.values
family_requests_attributes: individuals_request_params[:items_attributes]&.values,
request_type: "individual"
).initialize_only
if @partner_request.valid?
@total_items = @partner_request.total_items
Expand Down
9 changes: 2 additions & 7 deletions app/models/concerns/issued_at.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,18 @@ module IssuedAt
extend ActiveSupport::Concern

included do
before_create :initialize_issued_at
before_save :initialize_issued_at
scope :by_issued_at, ->(issued_at) { where(issued_at: issued_at.beginning_of_month..issued_at.end_of_month) }
scope :for_year, ->(year) { where("extract(year from issued_at) = ?", year) }
validates :issued_at, presence: true
validate :issued_at_cannot_be_before_2000
validate :issued_at_cannot_be_further_than_1_year
end

private

def initialize_issued_at
self.issued_at ||= created_at&.end_of_day
end

def issued_at_cannot_be_before_2000
if issued_at.present? && issued_at < Date.new(2000, 1, 1)
errors.add(:issued_at, "Cannot be before 2000")
errors.add(:issued_at, "cannot be before 2000")
end
end

Expand Down
3 changes: 3 additions & 0 deletions app/models/partner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Partner < ApplicationRecord
AGENCY_TYPES = {
"CAREER" => "Career technical training",
"ABUSE" => "Child abuse resource center",
"BNB" => "Basic Needs Bank",
"CHURCH" => "Church outreach ministry",
"COLLEGE" => "College and Universities",
"CDC" => "Community development corporation",
Expand All @@ -82,6 +83,7 @@ class Partner < ApplicationRecord
"LEGAL" => "Correctional Facilities / Jail / Prison / Legal System",
"CRISIS" => "Crisis/Disaster services",
"DISAB" => "Developmental disabilities program",
"DISTRICT" => "School District",
"DOMV" => "Domestic violence shelter",
"ECE" => "Early Childhood Education/Childcare",
"CHILD" => "Early childhood services",
Expand All @@ -96,6 +98,7 @@ class Partner < ApplicationRecord
"HOSP" => "Hospital",
"INFPAN" => "Infant/Child Pantry/Closet",
"LIB" => "Library",
"MHEALTH" => "Mental Health",
"MILITARY" => "Military Bases/Veteran Services",
"POLICE" => "Police Station",
"PREG" => "Pregnancy resource center",
Expand Down
2 changes: 0 additions & 2 deletions app/pdfs/distribution_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ def request_data
"Value/item",
"In-Kind Value Received",
"Packages"]]

inventory = nil
inventory = View::Inventory.new(@distribution.organization_id)
request_items = @distribution.request.request_items.map do |request_item|
RequestItem.from_json(request_item, @distribution.request, inventory)
Expand Down
10 changes: 3 additions & 7 deletions app/services/partners/family_request_create_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ module Partners
class FamilyRequestCreateService
include ServiceObjectErrorsMixin

attr_reader :partner_user_id, :comments, :family_requests_attributes, :partner_request
attr_reader :partner_user_id, :comments, :family_requests_attributes, :partner_request, :request_type

def initialize(partner_user_id:, family_requests_attributes:, comments: nil, for_families: false)
def initialize(partner_user_id:, family_requests_attributes:, request_type:, comments: nil)
@partner_user_id = partner_user_id
@comments = comments
@family_requests_attributes = family_requests_attributes.presence || []
@for_families = for_families
@request_type = request_type
end

def call
Expand Down Expand Up @@ -81,9 +81,5 @@ def convert_person_count_to_item_quantity(item_id:, person_count:)
def included_items_by_id
@included_items_by_id ||= Item.where(id: family_requests_attributes.pluck(:item_id)).index_by(&:id)
end

def request_type
@for_families ? "child" : "individual"
end
end
end
Loading

0 comments on commit 59bd77a

Please sign in to comment.