Skip to content

Conversation

@caseyhelbling
Copy link

NOTE: DO NOT discuss internal CommitChange information in your PR; this PR will be public.
Link back to the issue in the Tix repo when you need to do that.

Adds standardrb. Runs standardrb --fix, and fix-unsafely. Then fix all the items it couldn't fix by hand. Then update specs to passing.

@caseyhelbling caseyhelbling requested a review from wwahammy as a code owner April 23, 2025 03:57
@caseyhelbling caseyhelbling force-pushed the feature/clh/add-standardrb branch from db93d17 to 0a8d328 Compare April 23, 2025 04:06
@caseyhelbling caseyhelbling force-pushed the feature/clh/add-standardrb branch from 0a8d328 to d36a8b1 Compare April 23, 2025 16:39
Copy link
Author

@caseyhelbling caseyhelbling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments on why the changes are made. Some questions too... More to come.

params[:campaign][:end_datetime] = Chronic.parse(params[:campaign][:end_datetime]) if params[:campaign][:end_datetime].present?
end
current_campaign.update_attributes params[:campaign]
current_campaign.update params[:campaign]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Standard wants you to call update instead of update_attributes.

end
def current_nonprofit
result = Nonprofit.find_by(houid: params[:nonprofit_id])
if Rails.version < "5" && result.nil?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we could remove this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can. Please remove as a separate PR.

end
end
def remove
@image = ImageAttachment.find { |img| img.file_url == params[:src] }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find instead of select . first

:cancelled_at_gt_or_eq => (Time.current - 1.month).beginning_of_month,
:cancelled_at_lt => Time.current.beginning_of_month
cancelled_at_gt_or_eq: 1.month.ago.beginning_of_month,
cancelled_at_lt: Time.current.beginning_of_month
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surprised this didn't update to Time.zone.current...

def self.execute(statement)
puts statement if ENV['RAILS_ENV'] != 'production' && ENV['RAILS_LOG_LEVEL'] == 'debug' # log to STDOUT on dev/staging
return Qx.execute_raw(raw_expr_str(statement))
Rails.logger.debug statement if ENV["RAILS_ENV"] != "production" && ENV["RAILS_LOG_LEVEL"] == "debug" # log to STDOUT on dev/staging
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure what this line is supposed to be doing... I assume logging to debug is fine, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your guess is as good as mine

def update(table_name, settings, os={})
Qexpr.new @tree.put(:update, "UPDATE".bold.light_blue + " #{table_name}".blue + "\nSET".bold.light_blue + " #{settings.map{|key,val| "#{key.to_s}=#{Qexpr.quote(val)}"}.join(', ')}".blue)
def update(table_name, settings, os = {})
Qexpr.new @tree.put(:update, "UPDATE".bold.light_blue + " #{table_name}".blue + "\nSET".bold.light_blue + " #{settings.map { |key, val| "#{key}=#{Qexpr.quote(val)}" }.join(", ")}".blue)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious what all this .bold and .light_blue and .bue stuff is intended to do ...

Qx.select("host_id").from(:roles)
.where(user_id: user_id)
.and_where("roles.name IN ($names)", names: role_names)
.execute.pluck("host_id")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is pluck ok here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the code of pluck, I'd say it is.

.and_where("nonprofits.id=$id", id: np_id)
.group_by("users.email")
.execute.map{|h| h['email']}
.execute.pluck("email")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is pluck ok here?

Copy link
Author

@caseyhelbling caseyhelbling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed All the viles and left comments where I think little more looking is needed.

2025-04-24 at 10 39 PM

# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later

module SearchVector
ACCEPTED_TABLES = ["supporters", "payments"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused. Ithink.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does appear to be.

event = nil
else
event = Event.where('id = ?', data[:event_id]).first
event = Event.where(id: data[:event_id]).first
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly find_by(id: would be better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, please switch to find_by

if payment_ids.count < 1
raise ArgumentError.new("No payments are available to reverse.")
end
now = Time.current
Time.current
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this isn't needd.

donation.card = tokenizable
rec_don.card_id = tokenizable

rec_don.n_failures = 0
rec_don.save!
donation.save!
rec_don.supporter.supporter_notes.create!( content: "This supporter updated their card for their recurring donation with ID #{rec_don.id}", user: User.find(540))
rec_don.supporter.supporter_notes.create!(content: "This supporter updated their card for their recurring donation with ID #{rec_don.id}", user: User.find(540))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic user 540 again...

belongs_to :campaign_gift_option

validates :donation, presence: true
validates :campaign_gift_option, presence: true
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implicit with belongs_to now.

def bulk_delete
supporter_ids = if params[:selecting_all]
QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select("supporters.id").execute.map { |h| h["id"] }
QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select("supporters.id").execute.pluck("id")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pluck?

Copy link
Member

@wwahammy wwahammy Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be ideal if we had a spec to verify this Controller action

def modify
supporter_ids = if params[:selecting_all]
QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select("supporters.id").execute.map { |h| h["id"] }
QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select("supporters.id").execute.pluck("id")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pluck?

Copy link
Member

@wwahammy wwahammy Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be ideal if we had a spec to verify this Controller action

msg = errors.collect { |e| e[:msg] }.join('\n')
raise ValidationError.new(msg, errors.collect { |e| e[:data] })
msg = errors.pluck(:msg).join('\n')
raise ValidationError.new(msg, errors.pluck(:data))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pluck?

@wwahammy wwahammy changed the base branch from to-ruby-3.2 to run-standardrb April 28, 2025 23:34
Base automatically changed from run-standardrb to supporter_level_goal April 30, 2025 15:19
@wwahammy wwahammy changed the base branch from supporter_level_goal to add-standard.yml April 30, 2025 17:10
@wwahammy wwahammy force-pushed the feature/clh/add-standardrb branch from ba9554a to aa35d11 Compare April 30, 2025 17:11
Base automatically changed from add-standard.yml to supporter_level_goal April 30, 2025 20:47
Copy link
Member

@wwahammy wwahammy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @caseyhelbling! Sorry about delay of a review, I had thought I had finished and submitted the review but hadn't.

Mostly good but please review the places you removed the presence validation for belong_to relations. As I explain in one of the comments, we have automatic presence checking for belongs_to turned off.

Another comment:

  • Please ignore the comments I made about the Stripe date time issue. I realized later that Time.at(integer) == Time.zone.at(integer) is true which is what I was most worried about.

Lastly, we'll need to figure out what is going on with the specs that are newly failing. Let me know if you need help with anything of them.

EDIT:

Oh, one more thing: please undo the changes to the migrations, it seems like bad practice to modify them. It would be wiser, on a seperate PR, to squash them into just the schema and remove the old migrations.

Comment on lines +406 to +411
def self.create_from(root_tree_node)
er = ExpansionTree.new
er.root_node = root_tree_node
er
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened here? Why is this public instead of private?


supporter_ids = if params[:selecting_all]
QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select("supporters.id").execute.map { |h| h["id"] }
QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select("supporters.id").execute.pluck("id")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will. It would be nice if all of these were tested though.

include Controllers::NonprofitHelper

before_action :authenticate_nonprofit_user!, except: [:new, :create]
before_action :authenticate_nonprofit_user!, except: [:create]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change?

def bulk_delete
supporter_ids = if params[:selecting_all]
QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select("supporters.id").execute.map { |h| h["id"] }
QuerySupporters.full_filter_expr(current_nonprofit.id, params[:query]).select("supporters.id").execute.pluck("id")
Copy link
Member

@wwahammy wwahammy Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be ideal if we had a spec to verify this Controller action

require "rails_helper"
require "support/test_chunked_uploader"

# TODO: 6 tests marked pending that do not pass in the RAILS_ENV=ci but do in test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm

require "rails_helper"
require "support/test_chunked_uploader"

# TODO: 6 tests marked pending that do not pass in the RAILS_ENV=ci but do in test
Copy link
Member

@wwahammy wwahammy May 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather we keep the same set of tests in test and CI so it would be good to roll these back and figure out what's going on.

countries = countries.map{ |code, name| [code.upcase, name] }.sort{ |a, b| a[1] <=> b[1] }
countries.push([Settings.intntl.other_country.upcase, I18n.t('nonprofits.donate.info.supporter.other_country')]) if Settings.intntl.other_country
countries = all_countries.slice(*Settings.intntl.all_countries)
countries = countries.map { |code, name| [code.upcase, name] }.sort_by { |a| a[1] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about sort_by?

end
elsif (ccs_method == 'github')
git_hash = File.read("#{Rails.root}/CCS_HASH")
if Settings.ccs&.ccs_method.presence == "github"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks right


# TODO: figure out what this test is supposed to be doing
it "returns hash with empty misc settings" do
xit "returns hash with empty misc settings" do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this previously worked, we'll need to get it working before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants