mirror of
https://github.com/CHN-beta/nixos.git
synced 2024-10-22 23:39:02 +08:00
localPackages.hpcstat: sort before export
This commit is contained in:
parent
0f37c886a4
commit
8aeb290d0f
@ -262,7 +262,16 @@ namespace hpcstat::sql
|
||||
// export to markdown
|
||||
std::cout << "| 账号 | 使用核时 | 登陆次数(交互式) | 登陆次数(非交互式) | 成功任务数 | 失败任务数 | SSH密钥编号::指纹 |\n";
|
||||
std::cout << "| :--: | :--: | :--: | :--: | :--: | :--: | :--: |\n";
|
||||
for (auto& [key, stat] : stat_account)
|
||||
std::vector<std::pair<std::optional<std::string>, StatAccount>> stat_account_vector
|
||||
(stat_account.begin(), stat_account.end());
|
||||
auto compare = [](auto& a, auto& b)
|
||||
{
|
||||
if (a.first)
|
||||
{ if (b.first) return Keys[*a.first].PubkeyFilename < Keys[*b.first].PubkeyFilename; else return true; }
|
||||
else return false;
|
||||
};
|
||||
std::sort(stat_account_vector.begin(), stat_account_vector.end(), compare);
|
||||
for (auto& [key, stat] : stat_account_vector)
|
||||
std::cout << "| {} | {:.2f} | {} | {} | {} | {} | `{}::{}` |\n"_f
|
||||
(
|
||||
key ? Keys[*key].Username : "(unknown)", stat.CpuTime, stat.LoginInteractive, stat.LoginNonInteractive,
|
||||
|
Loading…
Reference in New Issue
Block a user