mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-20 10:45:27 +00:00
feat(dashboard): queue_on_property_save setting and the models waiting for their property to be saved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -473,6 +473,7 @@ namespace {
|
||||
c.Add(Int(UGC, "worker_nice", "Worker priority", "Linux nice value of the workers: 0 normal, 19 only when nothing else wants the CPU.", "0", 0, 19));
|
||||
c.Add(Unit(Int(UGC, "max_memory_mb", "Most memory for jobs", "Jobs whose estimated memory would go past this together wait for running ones; a bigger one runs alone. 0: no limit.", "0", 0, 1000000), "MB"));
|
||||
c.Add(Unit(Int(UGC, "max_model_bricks", "Biggest model", "Models with more bricks fail with that reason. 0: no limit.", "0", 0, 1000000), "bricks"));
|
||||
c.Add(Bool(UGC, "queue_on_property_save", "Only make models once their property is saved", "On: models already waiting (say, a server turning the UGC server on) aren't all made at once; a model is made once it is saved from Brick By Brick, made again by staff, or its property is saved. Off: every waiting model is made.", false));
|
||||
c.Add(Text(UGC, "pause_hours", "Pause hours", "Local hours in which no new jobs start, e.g. 18-23 or 22-6. Empty: never.", ""));
|
||||
c.Add(Unit(Int(UGC, "poll_interval_ms", "Look for new models every", "", "2000", 100, 600000, true), "ms"));
|
||||
c.Add(Int(UGC, "poll_batch", "Models taken at once", "", "32", 1, 1000, true));
|
||||
|
||||
@@ -264,6 +264,14 @@ namespace {
|
||||
for (const auto& [state, count] : counts) out[StateName(state)] = count;
|
||||
return out;
|
||||
}
|
||||
|
||||
// The models' counts, with how many of the waiting ones wait for their property to be saved while
|
||||
// queue_on_property_save is on (notQueued)
|
||||
nlohmann::json ModelCounts() {
|
||||
auto out = Counts(Database::Get()->GetUgcProcessCounts());
|
||||
if (UgcSetting("queue_on_property_save").value_or("0") == "1") out["notQueued"] = Database::Get()->CountUnqueuedUgcModels();
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
namespace UgcRoutes {
|
||||
@@ -385,7 +393,7 @@ namespace UgcRoutes {
|
||||
}
|
||||
if (searching) matches = { { "model", models(0, 1).second }, { "modular", total } };
|
||||
}
|
||||
JsonSuccess(reply, { { "counts", { { "model", Counts(Database::Get()->GetUgcProcessCounts()) }, { "modular", Counts(Database::Get()->GetModularBuildProcessCounts()) } } },
|
||||
JsonSuccess(reply, { { "counts", { { "model", ModelCounts() }, { "modular", Counts(Database::Get()->GetModularBuildProcessCounts()) } } },
|
||||
{ "totals", { { "model", Totals(Database::Get()->GetUgcProcessTotals(false)) }, { "modular", Totals(Database::Get()->GetUgcProcessTotals(true)) } } },
|
||||
{ "items", items }, { "total", total }, { "page", page }, { "size", size }, { "more", static_cast<uint64_t>(page + 1) * size < total }, { "kinds", kinds },
|
||||
{ "matches", matches }, { "ugcPublicUrl", Game::config->GetValue("ugc_public_url") }, { "canManage", Can(context, "ugc_manage") } });
|
||||
@@ -530,7 +538,7 @@ namespace UgcRoutes {
|
||||
const auto base = InternalUrl();
|
||||
// The database only on this thread; the worker only fetches
|
||||
nlohmann::json body = { { "success", true }, { "enabled", enabled }, { "online", online },
|
||||
{ "counts", { { "model", Counts(Database::Get()->GetUgcProcessCounts()) }, { "modular", Counts(Database::Get()->GetModularBuildProcessCounts()) } } } };
|
||||
{ "counts", { { "model", ModelCounts() }, { "modular", Counts(Database::Get()->GetModularBuildProcessCounts()) } } } };
|
||||
Workers::Reply(reply, context, false, [base, enabled, body = std::move(body)](HTTPReply& out) mutable {
|
||||
if (enabled) {
|
||||
const auto fetched = CachedGet(base + "/status", eCache::STATUS);
|
||||
|
||||
@@ -76,7 +76,9 @@
|
||||
function countCard(title, c) {
|
||||
return '<div class="col-md-6"><div class="card"><div class="card-body py-2"><div class="small text-body-secondary">' + esc(title) + '</div>' +
|
||||
fmt.badge(c.done + ' made', 'success') + ' ' + fmt.badge(c.pending + ' waiting', 'secondary') + ' ' + fmt.badge(c.failed + ' failed', c.failed ? 'danger' : 'secondary') +
|
||||
(c.empty ? ' ' + fmt.badge(c.empty + ' empty', 'light') : '') + '</div></div></div>';
|
||||
(c.empty ? ' ' + fmt.badge(c.empty + ' empty', 'light') : '') +
|
||||
(c.notQueued ? '<div class="small text-body-secondary mt-1" title="queue_on_property_save is on: a model is made once it is saved, made again, or its property is saved">' +
|
||||
esc(Number(c.notQueued).toLocaleString()) + ' of the waiting ones wait for their property to be saved</div>' : '') + '</div></div></div>';
|
||||
}
|
||||
// What making them all took, and what it saved (the rows' recorded stats; ones made before a stat existed don't count)
|
||||
function totalsCard(title, t) {
|
||||
|
||||
Reference in New Issue
Block a user