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

Simplify sorting and make it more readable #58

Merged
merged 11 commits into from
Apr 10, 2023
Merged

Simplify sorting and make it more readable #58

merged 11 commits into from
Apr 10, 2023

Conversation

S-S-X
Copy link
Member

@S-S-X S-S-X commented Apr 7, 2023

Main changes:

  • Overall LoC +105 −165 (which already includes few unrelated additions)
  • Makes filtering safe (deliberate invalid Lua pattern to crash server)
  • Makes filtering and sorting happen on demand, wont filter or sort if results wont be actually used.
  • Makes sorting function more readable and utilizes in place sorting.

Be aware that this is incomplete work.
There's 2 operation modes for sortfield == "1", this is because I was not sure how exactly it is supposed to work. Fixed.
Maybe it is supposed to be like a.from < b.from or a.to < b.to ? Fixed.

This will also modify original table but I think that shouldn't be problem, not 100% sure though... Checked this too, now makes shallow copy.

@S-S-X S-S-X requested a review from Athozus April 7, 2023 16:21
@Athozus
Copy link
Member

Athozus commented Apr 7, 2023

Be aware that this is incomplete work.

There's 2 operation modes for sortfield == "1", this is because I was not sure how exactly it is supposed to work.

Maybe it is supposed to be like a.from < b.from or a.to < b.to ?

This will also modify original table but I think that shouldn't be problem, not 100% sure though...

Okay, when I tried it worked very well. Maybe you will find issues, but the problem is that I wouldn't create a global function storing sorting data, and as this is a table of messages containing tables with info, it's hard to reproduce a table.sort-like function.

@Athozus Athozus added this to the 1.1.0 milestone Apr 7, 2023
@Athozus Athozus added Bug Something isn't working WIP labels Apr 7, 2023
Copy link
Member

@Athozus Athozus left a comment

Choose a reason for hiding this comment

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

Totally good, thx !

storage.lua Outdated Show resolved Hide resolved
storage.lua Outdated Show resolved Hide resolved
@Athozus Athozus marked this pull request as ready for review April 8, 2023 08:26
@Athozus Athozus removed the WIP label Apr 8, 2023
@S-S-X S-S-X marked this pull request as draft April 9, 2023 11:34
@S-S-X
Copy link
Member Author

S-S-X commented Apr 9, 2023

I've converted this back to draft because it still does not implement all functionality, we discussed this in mt-mods discord and results can be found from another PR which targets this branch.

So before merging this one either #59 should be merged and tested or missing functionality added directly to mail.sort_messages.

My personal preference, go with #59 instead of reinforcing formspec/ui dependency on mail.sort_messages.

@S-S-X S-S-X marked this pull request as ready for review April 10, 2023 10:35
@Athozus Athozus self-requested a review April 10, 2023 11:25
Copy link
Member

@Athozus Athozus left a comment

Choose a reason for hiding this comment

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

Very good work, for me it's doesn't present anything weird. I approve the merge.

No issues found.

@S-S-X S-S-X merged commit 67bda9a into master Apr 10, 2023
@Athozus Athozus deleted the message-sorting branch April 14, 2023 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants