mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
feat(ugc): models with no bricks are "empty", not failed
A model with no bricks has nothing to make: it gets its own state (is_optimized = 3), isn't counted as a failure or retried, shows as Empty on the UGC page (with its own filter and count), in the status and in Prometheus, and its downloads answer 404 like HKX. State names come from the enum (magic_enum). Migrations dlu/mysql/87 and dlu/sqlite/70 move the rows that failed only because they had no bricks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "magic_enum.hpp"
|
||||
|
||||
class IUgc {
|
||||
public:
|
||||
struct Model {
|
||||
@@ -40,8 +42,23 @@ public:
|
||||
PENDING = 0, // not made yet (or to be made again)
|
||||
DONE = 1, // the UGC server's files are made
|
||||
FAILED = 2, // gave up after the allowed attempts
|
||||
EMPTY = 3, // nothing to make: the model has no bricks (not a failure; never retried)
|
||||
};
|
||||
|
||||
// A state's name for the dashboard, the API and metrics ("pending", "done", "failed", "empty")
|
||||
static std::string ProcessStateName(eProcessState state) {
|
||||
std::string name(magic_enum::enum_name(state));
|
||||
for (auto& c : name) c = static_cast<char>(c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c);
|
||||
return name.empty() ? "unknown" : name;
|
||||
}
|
||||
|
||||
static std::optional<eProcessState> ParseProcessState(std::string_view text) {
|
||||
for (const auto state : magic_enum::enum_values<eProcessState>()) {
|
||||
if (ProcessStateName(state) == text) return state;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// A row's processing state, for the UGC server and the dashboard
|
||||
struct ProcessInfo {
|
||||
LWOOBJID id{};
|
||||
|
||||
Reference in New Issue
Block a user