Skip to content

Conversation

@caseyhelbling
Copy link

@caseyhelbling caseyhelbling commented Jun 18, 2025

Holy yak shaving...

This started as I was updating the FontAwesome version to 6 so we can get proper brand icons in place (including Bluesky.) That led me to the event listing page, and I noticed the events weren't showing up locally. I was seeing this error consistently:

app/legacy_lib/query_event_metrics.rb:84:in `for_listings'
method=GET path=/nonprofits/3624/events/listings format=/ controller=events action=listings status=500 duration=2463.45 view=0.00 db=2416.27 time=369267.90 exception=["ActiveRecord::StatementInvalid", "PG::DiskFull: ERROR:  could not resize shared memory segment \"/PostgreSQL.3859422886\" to 8388608 bytes: No space left on device\n"] exception_object=PG::DiskFull: ERROR:  could not resize shared memory segment "/PostgreSQL.3859422886" to 8388608 bytes: No space left on device

  
ActiveRecord::StatementInvalid (PG::DiskFull: ERROR:  could not resize shared memory segment "/PostgreSQL.3859422886" to 8388608 bytes: No space left on device
):

I debugged a little and learned my local DB was pretty small (so I tuned it up with the docker compose updates.)

That didn't fully solve the issue, but was partially helpful. Next, I decided to rewrite the expensive Qx query using regular Active Record/Arel, attempting to remove several of the joins and improve performance. The result is a query that is significantly more performant (I didn't fully benchmark but would guess 10x faster).

In the process, I didn't see any tests for the legacy_lib / query event metrics query so I wrote one for that as well.

Part of the polish was some light UI updates (slight space between listing items, left justify the heading titles, using h4 for heading title, etc. See picture)...

2025-06-17 at 11 07 PM

@caseyhelbling caseyhelbling requested a review from wwahammy June 18, 2025 03:56
h('span.u-inlineBlock.u-marginRight--20', [h('strong', `${label}: `), val || '0'])

const row = (icon, content) =>
const checkedInPercent = (checkedIn = 0 , total = 0) => {
Copy link
Author

Choose a reason for hiding this comment

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

Fixes bug with divide by 0 (NaN)...

, h(`div.fundraiser--${key}`, content)
const mixin = (content, count) =>
h('section.u-marginBottom--20.u-marginTop--30', [
h('h4.u-marginBottom--0.u-paddingX--20', count + ' ' + key.charAt(0).toUpperCase() + key.slice(1) + ' Events')
Copy link
Author

@caseyhelbling caseyhelbling Jun 18, 2025

Choose a reason for hiding this comment

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

Also, now display the count of events in the header/title:

@@ -0,0 +1,18 @@
class AddIndexesEvents < ActiveRecord::Migration[7.1]
def change
Copy link
Author

Choose a reason for hiding this comment

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

Add missing indexes for performance.

# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
FactoryBot.define do
factory :ticket do
event_discount
Copy link
Author

Choose a reason for hiding this comment

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

Lots of random factory updates to aid in getting test running.

@caseyhelbling caseyhelbling force-pushed the feature/clh/increase-db-size-and-indexes branch from a2a90a5 to 3acd120 Compare June 18, 2025 04:09
@wwahammy
Copy link
Member

wwahammy commented Jun 18, 2025

@caseyhelbling just to be clear, is the goal to recreate the exact behavior of QueryEventMetrics? If so, please move the spec changes into a separate PR so we can verify the specs are accurate. Then follow with this PR so we can see the specs still pass. Otherwise, we're trying to make sure the specs match behavior that we're replacing in the same PR and that's really hard to get right.

@caseyhelbling
Copy link
Author

@caseyhelbling just to be clear, is the goal to recreate the exact behavior of QueryEventMetrics? If so, please move the spec changes into a separate PR so we can verify the specs are accurate. Then follow with this PR so we can see the specs still pass. Otherwise, we're trying to make sure the specs match behavior that we're replacing in the same PR and that's really hard to get right.

#1229

Comment on lines +104 to +106
describe "for profile" do
skip "TODO"
end
Copy link
Member

Choose a reason for hiding this comment

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

Not an issue but a fun little feature of rspec I learned just in the last week.

If you write just describe "for profile" or it without a block, rspec treats it as if you told it to skip.

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