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

Sorting of the kernelrelease fact could be better #731

Open
gdubicki opened this issue Dec 16, 2022 · 1 comment
Open

Sorting of the kernelrelease fact could be better #731

gdubicki opened this issue Dec 16, 2022 · 1 comment

Comments

@gdubicki
Copy link
Contributor

gdubicki commented Dec 16, 2022

The values of kernelrelease fact for my Centos 7 nodes sorted in descending order are now sorted as alphanumeric strings, so for example like this:

3.10.0-957.5.1.el7.x86_64
3.10.0-862.14.4.el7.x86_64
3.10.0-693.21.1.el7.x86_64
3.10.0-1160.76.1.el7.x86_64
3.10.0-1127.19.1.el7.x86_64
3.10.0-1062.9.1.el7.x86_64
3.10.0-1062.18.1.el7.x86_64
3.10.0-1062.1.2.el7.x86_64

...while I would expect them interpreted as package versions and shown from latest to oldest so like this:

3.10.0-1127.19.1.el7.x86_64
3.10.0-1160.76.1.el7.x86_64
3.10.0-1062.18.1.el7.x86_64
3.10.0-1062.9.1.el7.x86_64
3.10.0-1062.1.2.el7.x86_64
3.10.0-957.5.1.el7.x86_64
3.10.0-862.14.4.el7.x86_64
3.10.0-693.21.1.el7.x86_64
@gdubicki gdubicki changed the title Sorting of kernelrelease facts could be better Sorting of the kernelrelease fact could be better Dec 16, 2022
@ArthurWuTW
Copy link
Contributor

ArthurWuTW commented Jul 30, 2024

I was first wondering if natural sort would solve this issue, so I gave it a try and screenshots show as follows:
image
image

I also do some refactorings:

  • natural_time_delta_sort Flag: declared in facts.py assigned True if fact=uptime and it's for setting sorting type of DataTable in _macros.html. Fact is also available in template so I think we can determine sorting type by fact directly without any flags. In other words, I'd like to add logics like if fact="uptime", then type="natural-time-delta" just inside template, and natural_time_delta_sort will be removed.
  • Sorter Map: Create a map whose key=fact and value=sorter. Key-value will be isolated in a new html file named _facts_sorter.html, now having (uptime, natural-time-delta) and (kernelrelease, natural). In this way it's easier to maintain if there is a new request for custom sorting.

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

No branches or pull requests

2 participants