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

Restore line item ordering #11014

Merged
merged 1 commit into from
Jun 25, 2023
Merged

Conversation

mkllnk
Copy link
Member

@mkllnk mkllnk commented Jun 15, 2023

What? Why?

The line item sorting by id has been replaced by sorting by completed_at time: ccb183d

While that's a good idea, the query param to order was only defined in the client Javascript and there was no default ordering. Line items also get their completed_at date from the order. So it's the same for all items of the same order and the ordering with that group of line items was random. Several specs became flaky.

Now we are sorting by id in addition. Items are first sorted by date and then by id if there's any ambiguity.

What should we test?

  • Log in as admin of a hub with plenty of complete orders and visit /admin/orders/bulk_management
  • Click "Completed at" header; take notice of the order range/ordering
  • Move to another pagination index number.
  • You might not have orders which should have been displayed on the first page

Release notes

Changelog Category: User facing changes

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

@mkllnk mkllnk self-assigned this Jun 15, 2023
@mkllnk mkllnk marked this pull request as ready for review June 15, 2023 05:59
Copy link
Member

@dacook dacook left a comment

Choose a reason for hiding this comment

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

Good work, and thanks!

I see one failed spec, which relates to the bulk order screen.

rspec ./spec/system/admin/bulk_order_cancellation_spec.rb:28 # 

But I'll assume this is due to another issue that you refer to, and have re-run to see.

@drummer83 drummer83 self-assigned this Jun 25, 2023
The line item sorting by id has been replaced by sorting by completed_at
time: ccb183d

While that's a good idea, the query param to order was only defined in
the client Javascript and there was no default ordering. Line items also
get their completed_at date from the order. So it's the same for all
items of the same order and the ordering with that group of line items
was random.

Now we are adding an order in addition. Items are first sorted by date
and then by id if there's any ambiguity.
@drummer83 drummer83 added the pr-staged-au staging.openfoodnetwork.org.au label Jun 25, 2023
@drummer83
Copy link
Contributor

Hi @mkllnk,
I tried to test this. However, I didn't see any line items on pages where they wouldn't belong even BEFORE this PR. Maybe bad luck...
So I thought by ID you meant the variant_id, but the results were not ordered by it AFTER the PR.
Then I thought, it's probably the Line Item ID of the order. So I added them to the screenshot below.

This is BEFORE your PR:
image

This is AFTER your PR:
image

We can see, that the line items of an order are now nicely sorted by line item ID. 👍

I think it would have been intuitive to use the variant_id as well - as I first thought - because that way similar orders would show the variants in the same order across different orders. The line item id instead depends on the order in which the customer put the items into the cart (I think), so similar orders will still show the variants in an order which seems random to the user. But that's not what this was about. I hope the specs are not flaky anymore now!

Thanks! Merging! 🚀

@drummer83 drummer83 merged commit 49db2f3 into openfoodfoundation:master Jun 25, 2023
@drummer83 drummer83 removed the pr-staged-au staging.openfoodnetwork.org.au label Jun 25, 2023
@mkllnk mkllnk deleted the specs branch June 26, 2023 00:27
@mkllnk
Copy link
Member Author

mkllnk commented Jun 26, 2023

Very good idea, Konrad. I just focused on the technical part of making the specs less flaky. But I like your idea of ordering by variant id as well. It would be a tiny papercut. Maybe create a good first issue for this?

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.

4 participants