Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce SolidusPromotions #5805

Merged
merged 524 commits into from
Oct 26, 2024

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Jun 26, 2024

Summary

This imports the solidus_friendly_promotions into the main solidusio/solidus repository, including all history.
This has been done using git filter-branch.

This is a big pull request, because it keeps the entire git history of the solidus_friendly_promotions repository. I encourage reviewers to review the last few commits, but better yet: Try it out on your stores.

See the README file as well as the MIGRATING.md file for instructions how to move from the legacy promotion system to solidus_promotions.

This gem supports

  • stackable promotions
  • much better code readability
  • the old and the new admin
  • creating discounted line items

And many more things. It should be well-linted, and has an extensive test suite.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

@github-actions github-actions bot added the changelog:repository Changes to the repository not within any gem label Jun 26, 2024
@mamhoff mamhoff force-pushed the import-solidus-friendly-promotions branch 2 times, most recently from f35fce1 to 7b1c00e Compare June 26, 2024 17:28
@mamhoff mamhoff changed the title WIP Import solidus friendly promotions Introduce SolidusPromotions Jun 26, 2024
@mamhoff mamhoff force-pushed the import-solidus-friendly-promotions branch from d1ba821 to 96ef390 Compare June 26, 2024 18:03
Copy link

codecov bot commented Jun 26, 2024

Codecov Report

Attention: Patch coverage is 98.73853% with 11 lines in your changes missing coverage. Please review.

Project coverage is 89.57%. Comparing base (25a41bf) to head (bf743d2).
Report is 525 commits behind head on main.

Files with missing lines Patch % Lines
...nd/solidus_promotions/admin/benefits_controller.rb 87.75% 6 Missing ⚠️
.../admin/solidus_promotions/promotions_controller.rb 87.50% 3 Missing ⚠️
...motions/app/models/solidus_promotions/condition.rb 93.54% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5805      +/-   ##
==========================================
+ Coverage   89.32%   89.57%   +0.24%     
==========================================
  Files         759      782      +23     
  Lines       17682    17965     +283     
==========================================
+ Hits        15795    16092     +297     
+ Misses       1887     1873      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mamhoff mamhoff marked this pull request as ready for review June 27, 2024 11:41
@mamhoff mamhoff requested a review from a team as a code owner June 27, 2024 11:41
@mamhoff mamhoff force-pushed the import-solidus-friendly-promotions branch 2 times, most recently from ec3837a to 7979816 Compare July 3, 2024 04:17
Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

I reviewed this with @mamhoff live and we left some comments together for things that might be worth improving. Looking forward to merge this!

@kennyadsl
Copy link
Member

Some things we'd need help with at this stage:

  1. Testing the upgrade path on a store with many promotions (bonus points for custom promotion rules/actions and for orders in the checkout state with a legacy promotion applied).
  2. Check the admin UI to see if everything is clear.
  3. Help rebasing the PR removing the merge commits (which refer to the old repository where this work started).

@mamhoff mamhoff force-pushed the import-solidus-friendly-promotions branch from 4ed9c4c to 49e99be Compare August 26, 2024 10:40
@mamhoff mamhoff force-pushed the import-solidus-friendly-promotions branch from 64f18c1 to a2afec0 Compare September 2, 2024 20:38
@jarednorman
Copy link
Member

I keep coming back and looking at this PR... and I'm still both excited and intimidated by it.

@mamhoff
Copy link
Contributor Author

mamhoff commented Sep 3, 2024

I keep coming back and looking at this PR... and I'm still both excited and intimidated by it.

Is there anything I can do to augment the excitement and reduce the anxiety?

@jarednorman
Copy link
Member

I probably should just take it for a spin on a store.

@kennyadsl
Copy link
Member

@jarednorman my anxiety level dropped after a very useful 1-hour session live with @mamhoff. 😄 BTW, testing this on a real/demo store could be a good way for getting the approve button pressed, which I'm going to do now.

@tvdeyen
Copy link
Member

tvdeyen commented Sep 4, 2024

@kennyadsl @jarednorman @mamhoff would it be helpful to record a session? So that the community also has a chance to get some insights on the design decision made here?

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

We use this in a real live store with lots of volume and personally have been attending countless pairings and reviews with @mamhoff during the last couple of months.

I am hitting the precious approve button now as well.

Amazing work Martin. I cannot add enough emojis to show my gratitude.

@jarednorman
Copy link
Member

would it be helpful to record a session?

That would be amazing.

@mamhoff
Copy link
Contributor Author

mamhoff commented Oct 8, 2024

@jarednorman What about we find a time and record it together? I have a hard time talking to the computer alone. :)

@tvdeyen
Copy link
Member

tvdeyen commented Oct 8, 2024

@jarednorman What about we find a time and record it together? I have a hard time talking to the computer alone. :)

Do I sense a Dead Code episode?

@jarednorman
Copy link
Member

@mamhoff Sorry for being very busy... how about a morning the week of November 21st? I don't mind getting up a little early, so the time zones work. Hit me up using the email on my profile.

I'd love to finally see this merged.

@tvdeyen tvdeyen added this to the 5.0 milestone Oct 9, 2024
@tvdeyen tvdeyen added release:major Breaking change on hold until next major release and removed release:major Breaking change on hold until next major release labels Oct 9, 2024
@tvdeyen tvdeyen removed this from the 5.0 milestone Oct 9, 2024
This reflects better what it does.
This looked a bit garbled without these extra w-100s.
Solidus Core now ships with a Null promotion handler.
We'll just be using Spree.solidus_version instead, like all the other
gems.
This is to indicate clearly that this JS is used for the backend UI.
This allows developers to more clearly see what they need to do in order
to implement custom promotion benefits.
This should give developers better hints as to how to use this gem.
As pointed out in
https://github.com/solidusio/solidus/pull/5383/files#r1391519251, the
new promotion code batch builder had worse performance characteristics
than the one in the legacy promotion system. This gets the
characteristics back to those of the legacy promotion system.

Time spent and memory usage still go up significantly and linearly with
the number of batches. I ran some specs with the following code:

```rb
  context "with a very large number of promotion codes" do
    let(:number_of_codes) { 10000 }

    it "creates the correct number of codes" do
      puts Benchmark.measure { subject.build_promotion_codes }
      expect(promotion.codes.size).to eq(number_of_codes)
    end
  end
```

With a 1000 codes, I measured:

```
Randomized with seed 49097
  1.036322   0.028977   1.065299 (  1.074396)
```

With 10000 codes, I measured:

```
Randomized with seed 33250
  9.606364   0.278920   9.885284 (  9.978242)
```

Memory usage went up linearly as well.
Much of this code has been lifted from some tax abstraction in core, and
some of the comments had not been updated.
@mamhoff mamhoff force-pushed the import-solidus-friendly-promotions branch from 21b59e8 to fa25fd3 Compare October 25, 2024 12:18
With the removal of our own .rubocop.yml, a few new linting problems
appeared.
@mamhoff mamhoff force-pushed the import-solidus-friendly-promotions branch from fa25fd3 to bf743d2 Compare October 25, 2024 12:53
@mamhoff
Copy link
Contributor Author

mamhoff commented Oct 25, 2024

I've managed to clean up the git history. We've gotten rid of the merge commits from solidus_friendly_promotions, and all the commits along with their messages are still there. I think this is now ready to go in 🥳

Copy link
Member

@jarednorman jarednorman left a comment

Choose a reason for hiding this comment

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

This is exciting!

@kennyadsl kennyadsl merged commit b36be11 into solidusio:main Oct 26, 2024
14 checks passed
@kennyadsl
Copy link
Member

Thanks again @mamhoff for the time to upstream this incredible work.

@jarednorman
Copy link
Member

Let's go!!! 👏🏻 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:repository Changes to the repository not within any gem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants