Remove old asset lists / masterdata endpoints

This commit is contained in:
Ethan O'Brien
2026-07-26 23:28:05 -05:00
parent 2056511bd1
commit 6523ad4d4a
9 changed files with 2 additions and 100667 deletions

View File

@@ -1,54 +0,0 @@
use actix_web::{HttpRequest, web, Responder, HttpResponse};
use actix_web::http::header::ContentType;
use jzon::object;
use lazy_static::lazy_static;
use std::collections::HashMap;
use std::sync::Mutex;
use crate::include_file;
lazy_static! {
static ref LIST_CACHE: Mutex<HashMap<String, String>> = Mutex::new(HashMap::new());
}
pub fn routes(cfg: &mut web::ServiceConfig) {
cfg.service(
web::scope("/assetLists")
.route("/supported", web::get().to(supported))
.route("{platform}/{LANG}", web::get().to(get))
);
}
async fn get(_req: HttpRequest) -> impl Responder {
let mut response = object!{};
response["Bundle"] = load_list("Bundle").into();
response["Movie"] = load_list("Movie").into();
response["Sound"] = load_list("Sound").into();
let body = jzon::stringify(response);
HttpResponse::Ok()
.insert_header(("content-type", ContentType::json()))
.insert_header(("content-length", body.len()))
.body(body)
}
fn load_list(name: &str) -> String {
if let Some(cached) = LIST_CACHE.lock().unwrap().get(name) {
return cached.clone();
}
let rel = format!("asset_lists/{}.json", name);
let list = crate::runtime::read_masterdata_file(&rel)
.and_then(|b| String::from_utf8(b).ok())
.unwrap_or_else(|| match name {
"Bundle" => include_file!("src/router/asset_lists/Bundle.json"),
"Movie" => include_file!("src/router/asset_lists/Movie.json"),
"Sound" => include_file!("src/router/asset_lists/Sound.json"),
_ => unreachable!(),
});
LIST_CACHE.lock().unwrap().insert(name.to_string(), list.clone());
list
}
async fn supported() -> impl Responder {
"SUPPORTED"
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -40,27 +40,6 @@ fn region_subdir(region: Region) -> &'static str {
}
}
pub fn get_all(region: Region) -> JsonValue {
let mut rv = object!{};
for file in dir_for(region).files() {
let table_name = file.path()
.file_stem()
.and_then(|s| s.to_str())
.unwrap_or_default();
if table_name.is_empty() {
continue;
}
if let Some(bytes) = csv_bytes(region, table_name) {
rv[table_name] = String::from_utf8(bytes).unwrap_or_default().into();
}
}
rv
}
pub fn csv_bytes(region: Region, name: &str) -> Option<Vec<u8>> {
let rel = format!("{}/{}.csv", region_subdir(region), name);
if let Some(bytes) = crate::runtime::read_masterdata_file(&rel) {

View File

@@ -1,31 +0,0 @@
use actix_web::{web, HttpRequest, HttpResponse, Responder};
use actix_web::http::header::ContentType;
use crate::router::databases::csv::{get_all, Region};
pub fn routes(cfg: &mut web::ServiceConfig) {
cfg.service(
web::scope("/masterdata")
.route("/supported", web::get().to(supported))
.route("/{platform}/{LANG}", web::get().to(mst))
);
}
async fn mst(req: HttpRequest) -> impl Responder {
let lang = req.match_info().get("LANG").unwrap_or("JP");
let region = match lang.to_ascii_uppercase().as_str() {
"JP" => Region::Jp,
_ => Region::En, // idk
};
let body = get_all(region);
let body = jzon::stringify(body);
HttpResponse::Ok()
.insert_header(("content-type", ContentType::json()))
.insert_header(("content-length", body.len()))
.body(body)
}
async fn supported() -> impl Responder {
"SUPPORTED"
}