Add sort results by title
This commit is contained in:
@@ -28,7 +28,7 @@ namespace platform {
|
||||
maxTitle = results.maxTitleSize();
|
||||
header_lengths = { 3, 10, maxModel, 11, 10, 12, 2, 3, 7, maxTitle };
|
||||
header_labels = { " #", "Date", "Model", "Score Name", "Score", "Platform", "SD", "C/P", "Time", "Title" };
|
||||
sort_fields = { "Date", "Model", "Score", "Time" };
|
||||
sort_fields = { "Date", "Model", "Score", "Time", "Title" };
|
||||
updateSize(rows, cols);
|
||||
// Initializes the paginator for each output type (experiments, datasets, result)
|
||||
for (int i = 0; i < static_cast<int>(OutputType::Count); i++) {
|
||||
@@ -346,9 +346,10 @@ namespace platform {
|
||||
{
|
||||
std::vector<std::tuple<std::string, char, bool>> sortOptions = {
|
||||
{"date", 'd', false},
|
||||
{"model", 'm', false},
|
||||
{"score", 's', false},
|
||||
{"time", 't', false},
|
||||
{"model", 'm', false},
|
||||
{"title", 'i', false},
|
||||
{"ascending+", '+', false},
|
||||
{"descending-", '-', false}
|
||||
};
|
||||
@@ -379,6 +380,9 @@ namespace platform {
|
||||
case 'm':
|
||||
sort_field = SortField::MODEL;
|
||||
break;
|
||||
case 'i':
|
||||
sort_field = SortField::TITLE;
|
||||
break;
|
||||
case '+':
|
||||
sort_type = SortType::ASC;
|
||||
break;
|
||||
|
@@ -88,6 +88,16 @@ namespace platform {
|
||||
return a.getDuration() > b.getDuration();
|
||||
});
|
||||
}
|
||||
void ResultsManager::sortTitle(SortType type)
|
||||
{
|
||||
if (empty())
|
||||
return;
|
||||
sort(files.begin(), files.end(), [type](const Result& a, const Result& b) {
|
||||
if (type == SortType::ASC)
|
||||
return a.getTitle() < b.getTitle();
|
||||
return a.getTitle() > b.getTitle();
|
||||
});
|
||||
}
|
||||
void ResultsManager::sortScore(SortType type)
|
||||
{
|
||||
if (empty())
|
||||
@@ -119,6 +129,9 @@ namespace platform {
|
||||
case SortField::DURATION:
|
||||
sortDuration(type);
|
||||
break;
|
||||
case SortField::TITLE:
|
||||
sortTitle(type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool ResultsManager::empty() const
|
||||
|
@@ -15,6 +15,7 @@ namespace platform {
|
||||
MODEL = 1,
|
||||
SCORE = 2,
|
||||
DURATION = 3,
|
||||
TITLE = 4,
|
||||
};
|
||||
class ResultsManager {
|
||||
public:
|
||||
@@ -24,6 +25,7 @@ namespace platform {
|
||||
void sortDate(SortType type);
|
||||
void sortScore(SortType type);
|
||||
void sortModel(SortType type);
|
||||
void sortTitle(SortType type);
|
||||
void sortDuration(SortType type);
|
||||
int maxModelSize() const { return maxModel; };
|
||||
int maxTitleSize() const { return maxTitle; };
|
||||
|
Reference in New Issue
Block a user