Skip to content

Conversation

@ancorgs
Copy link
Contributor

@ancorgs ancorgs commented Jun 13, 2025

Problem

The results of the search section in the description of drives, partitions and mdRaids are always sorted by name. Making it very hard to specify something like "the two biggest disks".

Solution

This implements support for implementing such searches with the syntax shown in the following examples:

{
  "search": {
    "sort": { "size": "desc" },
    "max": 2
  }
}

Several criteria can be specified to resolve ties.

{
  "search": {
    "sort": [
        { "size": "desc" },
        "name"
    ],
    "max": 2
  }
}

And, of course, all that can be combined with a condition to filter out devices before sorting.

{
  "search": {
    "condition": { "size": { "less": "1TiB" } },
    "sort": { "size": "desc" },
    "max": 2
  }
}

Testing

  • Added unit tests for the new parts
  • Tested manually

@coveralls
Copy link

coveralls commented Jun 13, 2025

Coverage Status

coverage: 62.527% (+0.1%) from 62.407%
when pulling 7b69732 on ancorgs:search_sort
into 1495361 on agama-project:master.

@ancorgs ancorgs force-pushed the search_sort branch 8 times, most recently from 21b74a6 to 5ef997b Compare June 16, 2025 11:29
@ancorgs ancorgs marked this pull request as ready for review June 16, 2025 11:35
@ancorgs ancorgs changed the title Initial support for sorting storage device during the search Initial support for sorting storage devices during the search Jun 16, 2025
Copy link
Contributor

@joseivanlopez joseivanlopez left a comment

Choose a reason for hiding this comment

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

LGTM

@ancorgs ancorgs merged commit 643e1c9 into agama-project:master Jun 16, 2025
8 checks passed
@imobachgs imobachgs mentioned this pull request Jun 30, 2025
imobachgs added a commit that referenced this pull request Jun 30, 2025
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.

3 participants