Query log wording: N answers so far, each kept for 7 days
"The query log holds 7 answers (stats.retention.queries)" read like 7 days' worth. The dashboard and the Statistics page now say how many answers it holds and how long each is kept; the dashboard's storage info has query_log_retention. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1b102a78f6
commit
250e734046
4 files changed
+23
-4
No files matched your search
@@ -294,8 +294,10 @@ type Database struct {
|
|||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
Bytes int64 `json:"bytes"`
|
Bytes int64 `json:"bytes"`
|
||||||
// Rows is how many answers the query log holds (statistics only).
|
// Rows is how many answers the query log holds (statistics only),
|
||||||
QueryLogRows *int64 `json:"query_log_rows,omitempty"`
|
// and QueryLogRetention how long it keeps them ("7d").
|
||||||
|
QueryLogRows *int64 `json:"query_log_rows,omitempty"`
|
||||||
|
QueryLogRetention string `json:"query_log_retention,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disk is a file system Jarl uses: what of Jarl's it holds, its size,
|
// Disk is a file system Jarl uses: what of Jarl's it holds, its size,
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ func (s *Server) storage(ctx context.Context) *api.Storage {
|
|||||||
if d := dbFile(statsDB, p); d != nil && s.cfg.Stats.Options().RetainQueries > 0 {
|
if d := dbFile(statsDB, p); d != nil && s.cfg.Stats.Options().RetainQueries > 0 {
|
||||||
if n, err := s.cfg.Stats.Store().QueryLogSize(ctx); err == nil {
|
if n, err := s.cfg.Stats.Store().QueryLogSize(ctx); err == nil {
|
||||||
d.QueryLogRows = &n
|
d.QueryLogRows = &n
|
||||||
|
d.QueryLogRetention = s.cfg.Stats.Status().Retention.Queries
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add(statsDB, filepath.Dir(p))
|
add(statsDB, filepath.Dir(p))
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ function storageCard(sg) {
|
|||||||
function storagePanel(sg) {
|
function storagePanel(sg) {
|
||||||
const dbRows = sg.databases.map((d) => [h("dt", null, d.label),
|
const dbRows = sg.databases.map((d) => [h("dt", null, d.label),
|
||||||
h("dd", null, h("strong", null, bytes(d.bytes)), " ", h("span", { class: "mono small muted" }, d.path),
|
h("dd", null, h("strong", null, bytes(d.bytes)), " ", h("span", { class: "mono small muted" }, d.path),
|
||||||
d.query_log_rows != null ? h("div", { class: "small muted" }, "the query log holds " + d.query_log_rows.toLocaleString() + " answers (stats.retention.queries)") : null)]);
|
d.query_log_rows != null ? h("div", { class: "small muted" }, "query log: " + d.query_log_rows.toLocaleString() + (d.query_log_rows === 1 ? " answer" : " answers") + " so far, each kept for " + retentionWords(d.query_log_retention) + " (stats.retention.queries)") : null)]);
|
||||||
return h("div", { class: "panel", id: "storage" },
|
return h("div", { class: "panel", id: "storage" },
|
||||||
h("h2", null, "Storage"),
|
h("h2", null, "Storage"),
|
||||||
h("dl", { class: "kv" }, dbRows, h("dt", null, "Together"), h("dd", null, h("strong", null, bytes(sg.total)))),
|
h("dl", { class: "kv" }, dbRows, h("dt", null, "Together"), h("dd", null, h("strong", null, bytes(sg.total)))),
|
||||||
@@ -183,3 +183,11 @@ function bytes(n) {
|
|||||||
while (n >= 1024 && i < units.length - 1) { n /= 1024; i++; }
|
while (n >= 1024 && i < units.length - 1) { n /= 1024; i++; }
|
||||||
return (n >= 100 || i === 0 ? Math.round(n) : n.toFixed(1)) + " " + units[i];
|
return (n >= 100 || i === 0 ? Math.round(n) : n.toFixed(1)) + " " + units[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// retentionWords: "7d" -> "7 days".
|
||||||
|
function retentionWords(r) {
|
||||||
|
const m = /^(\d+)([dhm])$/.exec(r || "");
|
||||||
|
if (!m) return r || "a while";
|
||||||
|
const word = { d: "day", h: "hour", m: "minute" }[m[2]];
|
||||||
|
return m[1] + " " + word + (m[1] === "1" ? "" : "s");
|
||||||
|
}
|
||||||
@@ -319,7 +319,7 @@ function exploreSince(since) {
|
|||||||
function dbTile(db, status) {
|
function dbTile(db, status) {
|
||||||
const keep = ((status || {}).retention || {}).queries;
|
const keep = ((status || {}).retention || {}).queries;
|
||||||
const sub = db.query_log_rows != null
|
const sub = db.query_log_rows != null
|
||||||
? "the query log holds " + compact(db.query_log_rows) + " answers (" + keep + ")"
|
? "query log: " + compact(db.query_log_rows) + (db.query_log_rows === 1 ? " answer" : " answers") + " so far, each kept for " + retentionWords(keep)
|
||||||
: "counters and top lists; no query log";
|
: "counters and top lists; no query log";
|
||||||
return h("a", { class: "card link", href: "#/", title: db.path + " · all of Jarl's databases: Dashboard → Storage" },
|
return h("a", { class: "card link", href: "#/", title: db.path + " · all of Jarl's databases: Dashboard → Storage" },
|
||||||
h("div", { class: "label" }, "Statistics database"), h("div", { class: "value" }, bytes(db.bytes)), h("div", { class: "sub" }, sub));
|
h("div", { class: "label" }, "Statistics database"), h("div", { class: "value" }, bytes(db.bytes)), h("div", { class: "sub" }, sub));
|
||||||
@@ -335,3 +335,11 @@ function diskTile(d) {
|
|||||||
h("div", { class: "seg other" + (u > 0.9 ? " full" : ""), style: { width: u * 100 + "%" } })),
|
h("div", { class: "seg other" + (u > 0.9 ? " full" : ""), style: { width: u * 100 + "%" } })),
|
||||||
h("div", { class: "sub" }, h("span", { class: u > 0.9 ? "warn-text" : "" }, Math.round(u * 100) + "% of " + bytes(d.total) + " used"), ", for " + d.holds.join(", ")));
|
h("div", { class: "sub" }, h("span", { class: u > 0.9 ? "warn-text" : "" }, Math.round(u * 100) + "% of " + bytes(d.total) + " used"), ", for " + d.holds.join(", ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// retentionWords: "7d" -> "7 days".
|
||||||
|
function retentionWords(r) {
|
||||||
|
const m = /^(\d+)([dhm])$/.exec(r || "");
|
||||||
|
if (!m) return r || "a while";
|
||||||
|
const word = { d: "day", h: "hour", m: "minute" }[m[2]];
|
||||||
|
return m[1] + " " + word + (m[1] === "1" ? "" : "s");
|
||||||
|
}
|
||||||
Reference in new issue
Block a user