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

Allow sorting by negative numbers #507

Merged
merged 2 commits into from
Jan 18, 2024
Merged

Allow sorting by negative numbers #507

merged 2 commits into from
Jan 18, 2024

Conversation

dsschult
Copy link
Contributor

One of my users noticed that negative numbers specified in meta ordering weren't being sorted correctly. This adds ns.SIGNED to the sorting, as well as modifying the tests to show it works.

Copy link

codecov bot commented Jan 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (943d77c) 88.70% compared to head (1c2cb06) 88.72%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #507      +/-   ##
==========================================
+ Coverage   88.70%   88.72%   +0.02%     
==========================================
  Files          25       25              
  Lines        2062     2066       +4     
==========================================
+ Hits         1829     1833       +4     
  Misses        233      233              

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

Copy link
Owner

@saimn saimn left a comment

Choose a reason for hiding this comment

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

Thanks for the patch, just a little question.

@@ -1 +1,2 @@
Order: 01
Order: -10
PartialOrder: 01
Copy link
Owner

Choose a reason for hiding this comment

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

The PartialOrder key doesn't seem to be used ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you don't set that, then the PartialOrder test fails:

        settings["albums_sort_reverse"] = False
        a = Album("dir1", settings, album["subdirs"], album["medias"], gal)
        a.sort_subdirs(["meta.partialorder", "meta.order"])
>       assert [d.name for d in a.albums] == list(["test1", "test2", "test3"])
E       AssertionError: assert ['test2', 'test1', 'test3'] == ['test1', 'test2', 'test3']
E         At index 0 diff: 'test2' != 'test1'
E         Use -v to get more diff

tests/test_gallery.py:251: AssertionError

I suppose I could have reordered the test assertion, but it's a good check that it's using PartialOrder instead of Order.

Copy link
Owner

Choose a reason for hiding this comment

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

Oh right, I missed that !
Sounds good them, thanks again.

@saimn saimn merged commit 27e10d4 into saimn:main Jan 18, 2024
8 checks passed
@dsschult dsschult deleted the sort_signed branch January 22, 2024 20:00
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.

2 participants