feat(ugc): processing totals on the UGC page; no shared icon preset for player models

- IUgc::GetUgcProcessTotals sums what the UGC server made, for models and
  for car and rocket builds: count, time spent (and how many are timed),
  CPU time, average and slowest, average and most memory (estimate),
  bricks, triangles and triangles saved (models whose count before hidden
  face removal is known). /api/ugc returns them as totals and the UGC page
  shows a card for each kind. Parity tested.
- Player models no longer have a shared icon preset: every one is a
  different size and shape, so its icon is fitted to it from the settings.
  The UGC server ignores a kind:model preset, the dashboard refuses to save
  one, and the icon editor hides the type buttons for models. One model's
  own icon values still work. Car and rocket build types keep theirs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-28 19:27:37 -05:00
parent bdb4c39db3
commit 4679edd2b2
13 changed files with 121 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
#include "MySQLDatabase.h"
#include <chrono>
#include <cmath>
namespace {
IUgc::ProcessInfo ReadUgcProcessInfo(PreparedStmtResultSet& result, bool modular) {
@@ -146,6 +147,24 @@ uint64_t MySQLDatabase::ResetUgcModelProcessing(const std::optional<LWOOBJID> id
return ExecuteUpdate("UPDATE ugc SET is_optimized = 0, process_attempts = 0, process_error = '', process_after = 0;");
}
IUgc::ProcessTotals MySQLDatabase::GetUgcProcessTotals(const bool modular) {
const std::string sql = modular
? "SELECT COUNT(*) AS made, SUM(CASE WHEN process_ms > 0 THEN 1 ELSE 0 END) AS timed, COALESCE(SUM(process_ms), 0) AS ms, COALESCE(SUM(process_cpu_ms), 0) AS cpu, "
"COALESCE(MAX(process_ms), 0) AS maxms, COALESCE(AVG(NULLIF(process_memory_kb, 0)), 0) AS memavg, COALESCE(MAX(process_memory_kb), 0) AS memmax, "
"0 AS bricks, 0 AS tris, 0 AS before_tris, 0 AS after_tris FROM ugc_modular_build WHERE is_optimized = 1;"
: "SELECT COUNT(*) AS made, SUM(CASE WHEN process_ms > 0 THEN 1 ELSE 0 END) AS timed, COALESCE(SUM(process_ms), 0) AS ms, COALESCE(SUM(process_cpu_ms), 0) AS cpu, "
"COALESCE(MAX(process_ms), 0) AS maxms, COALESCE(AVG(NULLIF(process_memory_kb, 0)), 0) AS memavg, COALESCE(MAX(process_memory_kb), 0) AS memmax, "
"COALESCE(SUM(brick_count), 0) AS bricks, COALESCE(SUM(triangle_count), 0) AS tris, "
"COALESCE(SUM(CASE WHEN triangle_count_before > 0 THEN triangle_count_before ELSE 0 END), 0) AS before_tris, "
"COALESCE(SUM(CASE WHEN triangle_count_before > 0 THEN triangle_count ELSE 0 END), 0) AS after_tris FROM ugc WHERE is_optimized = 1;";
auto result = ExecuteSelect(sql);
IUgc::ProcessTotals totals;
if (!result->next()) return totals;
const auto field = [&](const char* name) { return static_cast<uint64_t>(std::llround(result->getDouble(name))); };
totals = { field("made"), field("timed"), field("ms"), field("cpu"), field("maxms"), field("memavg"), field("memmax"), field("bricks"), field("tris"), field("before_tris"), field("after_tris") };
return totals;
}
uint64_t MySQLDatabase::ResetPropertyUgcModelProcessing(const LWOOBJID propertyId) {
return ExecuteUpdate("UPDATE ugc SET is_optimized = 0, process_attempts = 0, process_error = '', process_after = 0, priority = 1 "
"WHERE id IN (SELECT ugc_id FROM properties_contents WHERE property_id = ? AND ugc_id IS NOT NULL);", propertyId);