mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew
synced 2026-08-26 23:12:20 +08:00
Redo endpoints to get all data at once
This commit is contained in:
@@ -33,6 +33,23 @@ fn dir_for(region: Region) -> &'static Dir<'static> {
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
rv[table_name] = file.contents_utf8().unwrap_or_default().into();
|
||||
}
|
||||
}
|
||||
|
||||
rv
|
||||
}
|
||||
|
||||
pub fn csv_bytes(region: Region, name: &str) -> Option<&'static [u8]> {
|
||||
dir_for(region)
|
||||
.get_file(format!("{name}.csv"))
|
||||
|
||||
Reference in New Issue
Block a user