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

Secondary sort order in Market Offer Lists #4168

Closed
wants to merge 4 commits into from

Conversation

freimair
Copy link
Contributor

Fixes #4167

before:
Screenshot from 2020-04-14 15-06-21

after:
Screenshot from 2020-04-14 16-35-39

This check hasn't been in place before. However, during testing,
I encountered it once. Not sure why it can happen and how to react
properly.

NullPointerException is prohibited. Lets see if sorting issue pop
up sometime.
@ripcurlx ripcurlx added this to the v1.3.3 milestone Apr 14, 2020
@ripcurlx
Copy link
Contributor

ACK from a functionality point of view. Could you add this to the actual Offerbook as well?

@freimair
Copy link
Contributor Author

freimair commented May 3, 2020

Could you add this to the actual Offerbook as well?

Actually, I would prefer it that is a separate issue. Reasons are that it is not trivial to code that into Bisq, because the other lists can be sorted by clicking the column headers.

ensure orders with higher amounts are displayed first

I chose this representation because it is better than having it all scrambled up and because more BSQ trades are done with small amounts at the moment.

@freimair freimair requested a review from sqrrm May 11, 2020 15:47
Copy link
Contributor

@dmos62 dmos62 left a comment

Choose a reason for hiding this comment

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

NACK

The routine is very complicated, especially the primary comparator, because we're checking inside the comparator (twice, for some reason) for whether we're comparing sell offers or buy offers and then we're reversing order inside it as well. That shouldn't happen in the comparator. The comparator in both sell and buy cases should be Comparator.comparing(Offer::getPrice).thenComparing(Offer::getAmount), with a .reversed.() inserted where needed, for example: Comparator.comparing(Offer::getPrice).reversed().thenComparing(Offer::getAmount)

The rest of the functionality should be achieved by filtering the stream on whether it's a buy/sell (which is already being done at

&& e.getDirection().equals(OfferPayload.Direction.BUY))
and
&& e.getDirection().equals(OfferPayload.Direction.SELL))
); if nulls have to be handled (can there be offers without prices?), that should happen there as well (presuming we're not showing offers without prices).

* @param reversePrimarySortOrder
* @return
*/
private Comparator<Offer> getComparatorWithSecondarySortOrder(boolean reversePrimarySortOrder) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this name is preferable: getOfferComparator(...). The problem with getComparator was just that it didn't mention the object of comparison.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not requesting this change, since the whole method should be unnecessary.

@freimair
Copy link
Contributor Author

freimair commented May 15, 2020

@dmos62 originally, there is some double-check whether the Price is a crypto currency or not. Idk where that came from or what it is good for. But surely, there is a reason for that. So I kept it and just made it work. To your suggestion, of course, in a perfect world, that would be what we should do. Fully agree on that.

Please go ahead an open a PR doing it just like that.

I cannot not spend more time on that.

@dmos62
Copy link
Contributor

dmos62 commented May 15, 2020

Edit: posted link to branch with my changes, but then realised it will be easier to review if I squash to one commit and post to a second PR that supersedes this one.

dmos62 added a commit to dmos62/bisq that referenced this pull request May 15, 2020
A rewrite of @freimair's PR
bisq-network#4168.

Adds a secondary sort order of offers in market offer book by offer
amount that goes from high to low. Also, refactors-away overcomplicated
previous implementation of primary sort.

Co-authored-by: Florian Reimair <[email protected]>
Co-authored-by: cd2357 <[email protected]>
@dmos62
Copy link
Contributor

dmos62 commented May 15, 2020

@ripcurlx @sqrrm superseded by #4259.

@ripcurlx ripcurlx modified the milestones: v1.3.4, v1.3.6 Jun 4, 2020
@sqrrm
Copy link
Member

sqrrm commented Jul 1, 2020

Can this PR be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Secondary sort order in Offer lists
5 participants