Repository navigation
[#538] add --sort asc|desc option to list-backup command - #554
Conversation
|
You need to add yourself to https://github.com/pgmoneta/pgmoneta/blob/main/doc/DEVELOPERS.md#authors You need to reference the issue number in the commit subject |
|
Got it, do I need to close this one and create a new one |
| } | ||
| }; | ||
|
|
||
| static char* global_sort_option = NULL; |
There was a problem hiding this comment.
Which one needs to use a variable?
There was a problem hiding this comment.
set it in main, and use it in list-backup
| * @return 0 upon success, otherwise 1 | ||
| */ | ||
| int | ||
| pgmoneta_extract_backup_file(int server, char* label, char* relative_file_path, char* target_directory, char** target_file); |
There was a problem hiding this comment.
Where is this coming from ?
| #define MANAGEMENT_ARGUMENT_SERVERS "Servers" | ||
| #define MANAGEMENT_ARGUMENT_SERVER_SIZE "ServerSize" | ||
| #define MANAGEMENT_ARGUMENT_SERVER_VERSION "ServerVersion" | ||
| #define MANAGEMENT_ARGUMENT_SORT "Sort" |
| struct main_configuration* config; | ||
| struct json* request = NULL; | ||
| char* sort_order = NULL; | ||
| bool sort_desc = false; |
There was a problem hiding this comment.
true in cli, and false here - why ?
There was a problem hiding this comment.
Could you specify what you mean, the sort_desc variable is initialized to false here so that if the user doesn't specify a sort order, the backups will be sorted in ascending order by default.
There was a problem hiding this comment.
Its true here - https://github.com/pgmoneta/pgmoneta/pull/554/files#diff-c5e1c59efc3bb5961a6b24fd275c81da4e09fc9e47af81a05a9099651239f90fR464 - just make sure that the logic is easy to understand and aligned
There was a problem hiding this comment.
Sorry I still don't get it. Do you mean global_sort_option? But it's either "asc" or "desc"
There was a problem hiding this comment.
global_sort_option should be a local variable to main - so sort_option instead.
Do git grep sort and make sure that the bools are initialized in the same way
There was a problem hiding this comment.
Got it, I will fix it tomorrow
There was a problem hiding this comment.
I ran git grep sort and didn't find any other booleans related to 'asc' and 'desc', so everything is consistent now
|
|
||
| goto error; | ||
| } | ||
|
|
There was a problem hiding this comment.
There are some extra spaces - did you run ./uncrustify.sh ?
| } | ||
|
|
||
| // Check if sorting is requested | ||
| if (payload != NULL) |
There was a problem hiding this comment.
This should always be true
|
|
||
| int | ||
| pgmoneta_extract_backup_file(int server, char* label, char* relative_file_path, char* target_directory, char** target_file) | ||
| pgmoneta_extract_backup_file(int server, char* label, char* file, char* target_directory, char** target_file) |
|
@dancingactor No, you force push |
|
sorry for lots of mistakes, this is my first PR. I will do my best to avoid them in the future |
|
@dancingactor It is ok - we will get there |
|
You need to squash |
63bf305 to
e3d73f9
Compare
|
@jesperpedersen , I've updated all the problematic code, please take another look. Thanks for your time |
|
|
||
| pgmoneta_json_put(request, MANAGEMENT_ARGUMENT_SERVER, (uintptr_t)server, ValueString); | ||
|
|
||
| if (sort_order != NULL) |
There was a problem hiding this comment.
We should always add the argument, so if NULL then default should be _put
There was a problem hiding this comment.
got it, I've set the default value to "asc", is it ok?
list-backup command
|
Merged. Thanks for your contribution ! |
|
Thanks so much for your valuable feedback and time! Are there any other issues to contribute? I am eager to contirbute! |
|
@dancingactor You can comment on #557 and take that one |
implement #538
This PR adds a
--sortoption to thelist-backupCLI command, allowing users to sort backups by time in either ascending (asc) or descending (desc) order. This enhancement improves usability by enabling easier inspection of backup history in the desired order.Example Output
Input:
pgmoneta-cli list-backup primary --sort descOutput:
Input:
pgmoneta-cli list-backup primary --sort ascOutput:
Details