diff options
author | serxa <serxa@yandex-team.ru> | 2022-02-10 16:49:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:08 +0300 |
commit | d6d7db348c2cc64e71243cab9940ee6778f4317d (patch) | |
tree | bac67f42a02f9368eb4d329f5d79b77d0a6adc18 /library/cpp/lwtrace/mon/analytics/html_output.h | |
parent | 8d57b69dee81198a59c39e64704f7dc9f04b4fbf (diff) | |
download | ydb-d6d7db348c2cc64e71243cab9940ee6778f4317d.tar.gz |
Restoring authorship annotation for <serxa@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/lwtrace/mon/analytics/html_output.h')
-rw-r--r-- | library/cpp/lwtrace/mon/analytics/html_output.h | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/library/cpp/lwtrace/mon/analytics/html_output.h b/library/cpp/lwtrace/mon/analytics/html_output.h index f775f216b9..37d9fe3724 100644 --- a/library/cpp/lwtrace/mon/analytics/html_output.h +++ b/library/cpp/lwtrace/mon/analytics/html_output.h @@ -1,86 +1,86 @@ -#pragma once - -#include <util/string/printf.h> -#include <util/stream/str.h> -#include <util/generic/set.h> +#pragma once + +#include <util/string/printf.h> +#include <util/stream/str.h> +#include <util/generic/set.h> #include "data.h" - -namespace NAnalytics { - + +namespace NAnalytics { + inline TString ToHtml(const TTable& in) -{ +{ TSet<TString> cols; - bool hasName = false; - for (const TRow& row : in) { - hasName = hasName || !row.Name.empty(); - for (const auto& kv : row) { - cols.insert(kv.first); - } - } - - TStringStream ss; - ss << "<table>"; - ss << "<thead><tr>"; - if (hasName) { - ss << "<th>Name</th>"; - } + bool hasName = false; + for (const TRow& row : in) { + hasName = hasName || !row.Name.empty(); + for (const auto& kv : row) { + cols.insert(kv.first); + } + } + + TStringStream ss; + ss << "<table>"; + ss << "<thead><tr>"; + if (hasName) { + ss << "<th>Name</th>"; + } for (const TString& c : cols) { - ss << "<th>" << c << "</th>"; - } - ss << "</tr></thead><tbody>"; - - for (const TRow& row : in) { - ss << "<tr>"; - if (hasName) { - ss << "<th>" << row.Name << "</th>"; - } + ss << "<th>" << c << "</th>"; + } + ss << "</tr></thead><tbody>"; + + for (const TRow& row : in) { + ss << "<tr>"; + if (hasName) { + ss << "<th>" << row.Name << "</th>"; + } for (const TString& c : cols) { TString value; ss << "<td>" << (row.GetAsString(c, value) ? value : TString("-")) << "</td>"; - } - ss << "</tr>"; - } - ss << "</tbody></table>"; - - return ss.Str(); -} - + } + ss << "</tr>"; + } + ss << "</tbody></table>"; + + return ss.Str(); +} + inline TString ToTransposedHtml(const TTable& in) -{ +{ TSet<TString> cols; - bool hasName = false; - for (const TRow& row : in) { - hasName = hasName || !row.Name.empty(); - for (const auto& kv : row) { - cols.insert(kv.first); - } - } - - TStringStream ss; - ss << "<table><thead>"; - if (hasName) { - ss << "<tr>"; - ss << "<th>Name</th>"; - for (const TRow& row : in) { - ss << "<th>" << row.Name << "</th>"; - } - ss << "</tr>"; - } - - ss << "</thead><tbody>"; - + bool hasName = false; + for (const TRow& row : in) { + hasName = hasName || !row.Name.empty(); + for (const auto& kv : row) { + cols.insert(kv.first); + } + } + + TStringStream ss; + ss << "<table><thead>"; + if (hasName) { + ss << "<tr>"; + ss << "<th>Name</th>"; + for (const TRow& row : in) { + ss << "<th>" << row.Name << "</th>"; + } + ss << "</tr>"; + } + + ss << "</thead><tbody>"; + for (const TString& c : cols) { - ss << "<tr>"; - ss << "<th>" << c << "</th>"; - for (const TRow& row : in) { + ss << "<tr>"; + ss << "<th>" << c << "</th>"; + for (const TRow& row : in) { TString value; ss << "<td>" << (row.GetAsString(c, value) ? value : TString("-")) << "</td>"; - } - ss << "</tr>"; - } - ss << "</tbody></table>"; - - return ss.Str(); -} - -} + } + ss << "</tr>"; + } + ss << "</tbody></table>"; + + return ss.Str(); +} + +} |