Skip to content

Migrate payouts - #2384

Merged
EmCousin merged 27 commits into
antiwork:mainfrom
yashranaway:migrate-payouts
Dec 31, 2025
Merged

EmCousin merged 27 commits into
antiwork:mainfrom
yashranaway:migrate-payouts

Conversation

@yashranaway

Copy link
Copy Markdown
Contributor

Part of https://github.com/antiwork/gumroad/issues/856
Previous PR: #2383

This PR migrates the following page to Inertia:

  • /payouts

Before

image

After

(No visual changes)

Screen.Recording.2025-12-17.at.2.33.44.PM.mov

Without Data

image

Tests

image

AI disclosure

Used Claude Sonnet 4.5 for implementation and tests
All code manually reviewed by me

Confirmation

I have watched all Antiwork Livestreams

@yashranaway yashranaway left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hey @EmCousin, Updated the PR to now use router.reload with InertiaRails.merge , updated tests, All pass! Could you please review again?

Comment on lines +28 to +32
props: {
payout_presenter: payout_props.except(:past_payout_period_data, :pagination),
past_payout_period_data: InertiaRails.merge { payout_props[:past_payout_period_data] },
pagination: payout_props[:pagination]
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Uses InertiaRails.merge to append new page data to existing list on frontend

Comment on lines +490 to +495
const loadNextPage = () => {
router.reload({
data: { page: pagination.page + 1 },
only: ["past_payout_period_data", "pagination"],
});
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Partial reload to trigger server-side merging of past_payout_period_data

Comment on lines +54 to +57
expect(response).to be_successful
expect(inertia.props[:past_payout_period_data]).to be_an(Array)
expect(inertia.props[:past_payout_period_data].length).to eq(payments_per_page)
end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verifies that InertiaRails.merge correctly handles the data for infinite scroll

@yashranaway
yashranaway marked this pull request as ready for review December 17, 2025 11:49

@EmCousin EmCousin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's close to merging, so not closing - can you address the comment below? 👇

Comment thread app/controllers/balance_controller.rb Resolved
@yashranaway

Copy link
Copy Markdown
Contributor Author

@EmCousin _a Updated, Separated payout and pagination concerns and also updated the spec.

@neetogit-bot neetogit-bot Bot assigned EmCousin and unassigned yashranaway Dec 17, 2025
@EmCousin

Copy link
Copy Markdown
Contributor

@yashranaway can you fix the failing tests?

@yashranaway

Copy link
Copy Markdown
Contributor Author

@EmCousin Done, Could you trigger CI ? thanks :)

@neetogit-bot neetogit-bot Bot added the working Someone is actively working this — don't duplicate effort label Dec 24, 2025
@yashranaway

yashranaway commented Dec 24, 2025 •

Copy link
Copy Markdown
Contributor Author

@EmCousin I’m blocked on getting the test suite to run locally despite multiple attempts. Since the core changes are already approved by you, would you be able to take over and help?

If that’s easier, I’m fine closing the PR and letting someone else attempt.

only with #2395 🙏 , managed for #2384 sorry for the confustion

@yashranaway

Copy link
Copy Markdown
Contributor Author

Update : The failing tests are not related, added a commit to fix the Lints. Good to merge this PR!
cc: @EmCousin _a

@EmCousin

Copy link
Copy Markdown
Contributor

Thanks @yashranaway, I'll take a look next week as I'm AFK until Dec 29 🙏

@yashranaway

Copy link
Copy Markdown
Contributor Author

Sorry about the hassle and thanks to you, happy holidays @EmCousin ❤️

@yashranaway

Copy link
Copy Markdown
Contributor Author

@EmCousin can you please trigger CI again

@yashranaway

Copy link
Copy Markdown
Contributor Author

@EmCousin All tests passing, the 2 fails are unrelated!

@EmCousin EmCousin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Didn't see it in my last review; I'll help you implement those changes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pagination state should now derive from the props directly

Comment on lines 667 to 681

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No, the whole point of letting Inertia handling the props merging is to no longer to have this code at all.
A simple router.reload({ data: { page: pagination.next } }) should be doing the job here

router.reload({
  data: { page: pagination.next },
  only: ["pagination", "payouts"],
  onStart: () => setIsLoading(true),
  onFinish: () => setIsLoading(false),
})

Comment thread app/controllers/balance_controller.rb Outdated
pagination:
}
props: {
payout_presenter: payout_presenter.payout_props,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should expose the payout props directly and not create extra nesting here.

Comment thread app/controllers/balance_controller.rb Outdated
@@ -19,26 +19,15 @@ def index
next_payout_period_data: seller_stats[:next_payout_period_data],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

next_payout_period_data should be fetched only when necessary. Right now it is always evaluated when hitting this endpoint. That means when performing a partial reload to retrieve the next page of past payouts, this code is executed although it is not used in the frontend. It needs to be moved to a separate method and invoked from within a lambda to benefit from lazy data evaluation

Comment thread app/controllers/balance_controller.rb Outdated
@@ -19,26 +19,15 @@ def index
next_payout_period_data: seller_stats[:next_payout_period_data],
processing_payout_periods_data: seller_stats[:processing_payout_periods_data],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same comment for processing_payout_periods_data

Comment thread app/controllers/balance_controller.rb Outdated
processing_payout_periods_data: seller_stats[:processing_payout_periods_data],
seller: current_seller,
pagination:,
past_payouts:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same comment for past_payouts

@yashranaway

Copy link
Copy Markdown
Contributor Author

Didn't see it in my last review; I'll help you implement those changes

Should I start addressing those changes?

@EmCousin

Copy link
Copy Markdown
Contributor

@yashranaway yes

@yashranaway

Copy link
Copy Markdown
Contributor Author

@EmCousin Addressed all the changes, Can you review?

@yashranaway

Copy link
Copy Markdown
Contributor Author

@EmCousin autofix 😅

@yashranaway

Copy link
Copy Markdown
Contributor Author

@EmCousin All tests pass! The failing test seems unrelated.

@yashranaway

yashranaway commented Dec 30, 2025 •

Copy link
Copy Markdown
Contributor Author

Same test failed, should I try fixing it?

@EmCousin EmCousin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @yashranaway !

@EmCousin
EmCousin merged commit 2caf1d9 into antiwork:main Dec 31, 2025
65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

working Someone is actively working this — don't duplicate effort

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants