feat(core): reclassify the content_kind of already-imported owned rows
CI / Build, lint & test (push) Failing after 1m57s
CI / Build, lint & test (push) Failing after 1m57s
A profile import is once-only — the same fingerprint no-ops and a different one is refused — so a taxonomy correction cannot arrive by re-importing. Every club imported before content_kind existed still records its coaches, kits and consumables as players, because Core defaults an unstated row to `player`. Core stays generic: the caller supplies card_id -> kind, since only the game adapter can map its own taxonomy. One transaction, idempotent, scoped to a single game so a shared database cannot be reclassified across games, and an assignment nobody owns is reported rather than invented.
This commit is contained in:
+19
@@ -57,6 +57,25 @@ async fn main() -> Result<()> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// `openfut-core reclassify <request.json>` — correct the content_kind of
|
||||
// already-imported owned rows. A profile import is once-only, so a taxonomy
|
||||
// fix cannot arrive by re-importing; the adapter supplies card_id -> kind
|
||||
// because only it can map its own taxonomy. Idempotent.
|
||||
if std::env::args().nth(1).as_deref() == Some("reclassify") {
|
||||
let path = std::env::args()
|
||||
.nth(2)
|
||||
.context("usage: openfut-core reclassify <request.json>")?;
|
||||
let pool = db::init_pool(&cfg.database_url, cfg.max_connections).await?;
|
||||
db::run_migrations(&pool).await?;
|
||||
let raw = std::fs::read_to_string(&path)
|
||||
.with_context(|| format!("read reclassify request {path}"))?;
|
||||
let req: openfut_core::services::import::ReclassifyRequest =
|
||||
serde_json::from_str(&raw).context("parse reclassify request JSON")?;
|
||||
let outcome = openfut_core::services::import::reclassify_owned_content(&pool, &req).await?;
|
||||
println!("{}", serde_json::to_string_pretty(&outcome)?);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
info!("OpenFUT Core starting on {}", cfg.listen_addr);
|
||||
|
||||
let pool = db::init_pool(&cfg.database_url, cfg.max_connections).await?;
|
||||
|
||||
Reference in New Issue
Block a user