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

Product totals - custom units #4609

Merged
merged 14 commits into from
Nov 22, 2024
Merged

Product totals - custom units #4609

merged 14 commits into from
Nov 22, 2024

Conversation

awwaiid
Copy link
Collaborator

@awwaiid awwaiid commented Aug 25, 2024

Implement #4408

  • Adds units when feature is enabled and there are any units
  • Changes sort to be by name instead of by qty

image

@@ -23,23 +23,8 @@
end
end

context 'when item name is nil' do
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From a production snapshot:

pry(main)> Partners::ItemRequest.where(name: nil).count
  Partners::ItemRequest Count (15.1ms)  SELECT COUNT(*) FROM "item_requests" WHERE "item_requests"."name" IS NULL
=> 0

@awwaiid awwaiid marked this pull request as ready for review August 25, 2024 02:57
@awwaiid awwaiid requested review from dorner and cielf August 25, 2024 02:58
@awwaiid awwaiid added this to the Request Units (Packs) milestone Aug 25, 2024
@awwaiid awwaiid linked an issue Aug 25, 2024 that may be closed by this pull request
2 tasks
Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

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

1/ Could we use the plural for the custom units in this?
2/ We're putting a dash, but no unit when it's that situation where they just have units. maybe we should say "units" there.
Screenshot 2024-08-27 at 1 44 24 PM

@awwaiid
Copy link
Collaborator Author

awwaiid commented Sep 1, 2024

I'm wondering which is better, Pads - units or Pads. Also ... the way we've implemented units elsewhere end up recording an empty string. We could maybe explicitly record "units" as the individual-units default recorded in the database.

@cielf
Copy link
Collaborator

cielf commented Sep 1, 2024

Which is better is a fair question. Is it a Wednesday question?

@dorner
Copy link
Collaborator

dorner commented Sep 2, 2024

I'd probably prefer it like this:

  • Pads (individual)
  • Pads (in packs)

@cielf
Copy link
Collaborator

cielf commented Sep 2, 2024

I'd probably prefer it like this:

  • Pads (individual)
  • Pads (in packs)

I think (in packs) implies the number of pads that happen to be in packs, as opposed to the number of packs. I kind of like the parentheses, though.

This is still the whole naming things issue - but I think we should be consistent between what we use for the partners and what we use for the banks -- because they do have conversations.

How about:

  • Pads (units)
  • Pads (packs)

I don't like "units", because of the naming conflict with "Custom Request Units" , but it's what we got from the banks. We could check if "pieces" would work for them, maybe?

@awwaiid
Copy link
Collaborator Author

awwaiid commented Oct 13, 2024

From our discussion on the call today, this is now updated to use plural when units are specified and blank otherwise.

@awwaiid awwaiid requested a review from cielf October 13, 2024 16:19
cielf
cielf previously requested changes Oct 14, 2024
Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

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

Two wee things:
1/ The sort should be lower-case alpha. (we are standardizing on that)
2/ If we're not showing the unit, we shouldn't show the dash either, methinks.
Screenshot 2024-10-14 at 10 03 37 AM

@awwaiid
Copy link
Collaborator Author

awwaiid commented Nov 3, 2024

Two wee things: 1/ The sort should be lower-case alpha. (we are standardizing on that) 2/ If we're not showing the unit, we shouldn't show the dash either, methinks.

Fixed!

@awwaiid awwaiid requested a review from cielf November 3, 2024 17:58
@cielf cielf dismissed their stale review November 7, 2024 14:16

Addressed.

Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

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

LGTM. Over to @dorner for technical.

Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

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

Mostly minor suggestions.

app/services/requests_total_items_service.rb Outdated Show resolved Hide resolved
item_found = items_names.find { |item| item["id"] == id }
item_found&.fetch('name') || '*Unknown Item*'
def item_name(item_request)
if Flipper.enabled?(:enable_packs) && item_request.request_unit.present?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Didn't we extract this into a method in a different PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, in the not-yet-merged PR. This refactor I think will make it trivial to cross-use the two -- like maybe we merge that other one first an then I'll update this one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Eh. I made them identical now.

spec/services/requests_total_items_service_spec.rb Outdated Show resolved Hide resolved
spec/services/requests_total_items_service_spec.rb Outdated Show resolved Hide resolved

it 'return items with correct quantities calculated' do
expect(subject).to eq({
sample_items.first.name => 20,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we hardcode these names please?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed! And then some!

awwaiid and others added 3 commits November 17, 2024 15:47
Co-authored-by: Daniel Orner <daniel.orner@flipp.com>
Co-authored-by: Daniel Orner <daniel.orner@flipp.com>
Co-authored-by: Daniel Orner <daniel.orner@flipp.com>
@awwaiid awwaiid requested a review from dorner November 17, 2024 21:18
Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

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

LGTM!

@dorner dorner merged commit 1025cf5 into main Nov 22, 2024
22 checks passed
@dorner dorner deleted the 4408-product-totals-units branch November 22, 2024 01:09
Copy link
Contributor

@awwaiid: Your PR Product totals - custom units is part of today's Human Essentials production release: 2024.11.24.
Thank you very much for your contribution!

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.

[PACKS] #13 Calcuate Product Totals
3 participants