Display free account's tasks

This commit is contained in:
alejo committed 2026-10-19 18:16:21 -03:00
1 parent 6cb5a8611f
commit 315a2102a7
2 files changed
+13 -6

No files matched your search

+3 -2
View File
@@ -78,8 +78,9 @@ goes back to `$VISUAL` / `$EDITOR` / nano / vim / vi. The choice is stored in
* Account panel: one row per account, judged by its tasks: `Busy` if any is * Account panel: one row per account, judged by its tasks: `Busy` if any is
Testing, Limit reset or Wait; else `Taken` if any is Prompt; else `Free` Testing, Limit reset or Wait; else `Taken` if any is Prompt; else `Free`
(only Done, Frozen or Uploading tasks, or no tasks). The TASKS column lists (only Done, Frozen or Uploading tasks, or no tasks). The TASKS column lists
the tasks at that level. Rows are sorted most free first: Free, Taken, Busy, the tasks at that level, so a Free account shows its Uploading, Frozen and
fewer tasks first, ties by name (see `levelOf` in `Display.cpp` and Done tasks (`-` if it has none). Rows are sorted most free first: Free, Taken, Busy;
within Taken and Busy fewer tasks first, ties by name (see `levelOf` in `Display.cpp` and
`StatusUtil::isBusy` / `isTaken` to change the rules). `StatusUtil::isBusy` / `isTaken` to change the rules).
* Deleting an account leaves its tasks unassigned (`-`). * Deleting an account leaves its tasks unassigned (`-`).
* Names are case-insensitive; the original spelling is kept. * Names are case-insensitive; the original spelling is kept.
+10 -4
View File
@@ -127,7 +127,8 @@ std::string Display::renderAccounts(std::time_t now) const {
std::sort(views.begin(), views.end(), taskLess); std::sort(views.begin(), views.end(), taskLess);
// One row per account. Its level is the most taken of its tasks // One row per account. Its level is the most taken of its tasks
// (Busy > Taken > Free); the TASKS column lists the tasks at that level. // (Busy > Taken > Free); the TASKS column lists the tasks at that level
// (for a Free account that is its Uploading, Frozen and Done tasks).
struct AccountView { struct AccountView {
std::string name; std::string name;
AccountLevel level; AccountLevel level;
@@ -138,6 +139,7 @@ std::string Display::renderAccounts(std::time_t now) const {
for (const std::string& account : db_.listAccounts()) { for (const std::string& account : db_.listAccounts()) {
std::vector<std::string> busy; std::vector<std::string> busy;
std::vector<std::string> taken; std::vector<std::string> taken;
std::vector<std::string> free;
for (const TaskView& view : views) { for (const TaskView& view : views) {
if (view.account != account) { if (view.account != account) {
continue; continue;
@@ -147,6 +149,8 @@ std::string Display::renderAccounts(std::time_t now) const {
busy.push_back(view.name); busy.push_back(view.name);
} else if (level == AccountLevel::Taken) { } else if (level == AccountLevel::Taken) {
taken.push_back(view.name); taken.push_back(view.name);
} else {
free.push_back(view.name);
} }
} }
@@ -160,17 +164,19 @@ std::string Display::renderAccounts(std::time_t now) const {
entry.tasks = taken; entry.tasks = taken;
} else { } else {
entry.level = AccountLevel::Free; entry.level = AccountLevel::Free;
entry.tasks = free;
} }
accounts.push_back(entry); accounts.push_back(entry);
} }
// Most free first: Free, then Taken, then Busy; within a level fewer tasks // Most free first: Free, then Taken, then Busy; within Taken and Busy fewer
// first. listAccounts is alphabetical and stable_sort keeps that for ties. // tasks first (Free accounts are all equally free). listAccounts is
// alphabetical and stable_sort keeps that order for ties.
std::stable_sort(accounts.begin(), accounts.end(), [](const AccountView& a, const AccountView& b) { std::stable_sort(accounts.begin(), accounts.end(), [](const AccountView& a, const AccountView& b) {
if (a.level != b.level) { if (a.level != b.level) {
return levelRank(a.level) < levelRank(b.level); return levelRank(a.level) < levelRank(b.level);
} }
return a.tasks.size() < b.tasks.size(); return a.level != AccountLevel::Free && a.tasks.size() < b.tasks.size();
}); });
TextTable table({"ACCOUNT", "STATUS", "TASKS"}); TextTable table({"ACCOUNT", "STATUS", "TASKS"});