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