Skip to content

Commit

Permalink
latest changes for alpha2 before move to alpha3
Browse files Browse the repository at this point in the history
  • Loading branch information
ResuBaka committed Nov 23, 2024
1 parent de2fbdf commit 2a9bc62
Show file tree
Hide file tree
Showing 18 changed files with 1,033 additions and 123 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
},
"dependencies": {
"@artmizu/nuxt-prometheus": "^2.4.0",
"@pinia/nuxt": "^0.5.3",
"nuxt": "^3.12.4",
"vue": "^3.4.37",
"vue-router": "^4.4.3",
"@pinia/nuxt": "^0.7.0",
"nuxt": "^3.14.1592",
"vue": "^3.5.13",
"vue-router": "^4.4.5",
"ws": "^8.18.0",
"zod": "^3.23.8"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@nuxt/devtools": "^1.3.9",
"@biomejs/biome": "^1.9.4",
"@nuxt/devtools": "^1.6.1",
"@types/ws": "^8.5.12",
"sass": "^1.77.8",
"@vueuse/shared": "^10.11.1",
"vuetify": "^3.6.14",
"vuetify-nuxt-module": "^0.16.1"
"@vueuse/shared": "^11.3.0",
"vuetify": "^3.7.4",
"vuetify-nuxt-module": "^0.18.3"
}
}
4 changes: 2 additions & 2 deletions pages/buildings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ const { data, pending, refresh } = await useLazyFetch(
if (Object.keys(options.query).length > 2) {
const query = { ...options.query };
if (new_api) {
delete options.query.per_page;
delete query.per_page;
} else {
delete options.query.perPage;
delete query.perPage;
}
router.push({ query });
} else if (options.query.page <= 1) {
Expand Down
4 changes: 2 additions & 2 deletions pages/claims/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ const {
if (Object.keys(options.query).length > 2) {
const query = { ...options.query };
if (new_api) {
delete options.query.per_page;
delete query.per_page;
} else {
delete options.query.perPage;
delete query.perPage;
}
router.push({ query });
} else if (options.query.page <= 1) {
Expand Down
4 changes: 2 additions & 2 deletions pages/items/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ const { data, pending, refresh } = await useLazyFetch(
if (Object.keys(options.query).length > 2) {
const query = { ...options.query };
if (new_api) {
delete options.query.per_page;
delete query.per_page;
} else {
delete options.query.perPage;
delete query.perPage;
}
router.push({ query });
} else if (options.query.page <= 1) {
Expand Down
4 changes: 2 additions & 2 deletions pages/players/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ const {
if (Object.keys(options.query).length > 2) {
const query = { ...options.query };
if (new_api) {
delete options.query.per_page;
delete query.per_page;
} else {
delete options.query.perPage;
delete query.perPage;
}
router.push({ query });
} else if (options.query.page <= 1) {
Expand Down
2 changes: 2 additions & 0 deletions rust/api-server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion rust/api-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ edition = "2021"
members = [".", "api", "service", "entity", "migration"]

[workspace.dependencies]
sea-orm = { version = "1.0.0", features = [ "sqlx-all", "runtime-tokio-rustls", "macros" ] }
sea-orm = { version = "1.0.0", features = [ "sqlx-postgres", "runtime-tokio-rustls", "macros" ] }
serde_json = "1.0.120"
serde = { version = "1.0.204", features = ["derive"] }
tokio = { version = "^1.39.1", features = [ "full" ] }
log = "0.4.22"
axum = "0.7.5"
reqwest = { version = "0.12.5", features = ["json", "default" , "zstd", "brotli", "deflate", "gzip", "stream"] }
hyper = { version = "1.4.1", features = ["full"] }
rayon = "1.10.0"

[dependencies]
api = { path = "api" }
Expand Down
1 change: 1 addition & 0 deletions rust/api-server/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ reqwest = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
hyper = { workspace = true }
rayon = { workspace = true }
tokio-util = "0.7.11"
indicatif = "0.17.8"
lazy_static = "1.5.0"
Expand Down
2 changes: 1 addition & 1 deletion rust/api-server/api/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) struct Config {
}

#[derive(Deserialize, Debug, Clone)]
enum ImportType {
pub(crate) enum ImportType {
File,
Game,
}
Expand Down
63 changes: 7 additions & 56 deletions rust/api-server/api/src/items_and_cargo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub(crate) struct ItemsAndCargoResponse {
items: Vec<ItemCargo>,
tags: Vec<String>,
tiers: Vec<i32>,
#[serde(rename = "perPage")]
per_page: u64,
total: u64,
page: u64,
Expand All @@ -61,10 +60,10 @@ pub(crate) async fn list_items_and_cargo(
let tag = params.tag;

let (items, items_tags, items_tiers, cargos, cargos_tags, cargos_tiers) = tokio::join!(
QueryCore::all_items(&state.conn),
QueryCore::search_items_desc(&state.conn, &search, &tier, &tag),
QueryCore::find_unique_item_tags(&state.conn),
QueryCore::find_unique_item_tiers(&state.conn),
QueryCore::all_cargos_desc(&state.conn),
QueryCore::search_cargos_desc(&state.conn, &search, &tier, &tag),
QueryCore::find_unique_cargo_tags(&state.conn),
QueryCore::find_unique_cargo_tiers(&state.conn),
);
Expand All @@ -81,62 +80,14 @@ pub(crate) async fn list_items_and_cargo(
let mut merged_tiers = merge_tiers(items_tiers, cargos_tiers);
let merged_items_and_cargo = merge_items_and_cargo(items, cargos);

let filtered_items_and_cargo = merged_items_and_cargo
.into_iter()
.filter(|item| match item {
ItemCargo::Item(item) => {
let mut found = true;

if let Some(tag) = &tag {
found = item.tag.eq(tag);
}

if found {
if let Some(tier) = &tier {
found = item.tier.eq(tier);
}
}

if found {
if let Some(search) = &search {
found = item.name.to_lowercase().contains(search);
}
}

found
}
ItemCargo::Cargo(cargo) => {
let mut found = true;

if let Some(tag) = &tag {
found = cargo.tag.eq(tag);
}

if found {
if let Some(tier) = &tier {
found = cargo.tier.eq(tier);
}
}

if found {
if let Some(search) = &search {
found = cargo.name.to_lowercase().contains(search);
}
}

found
}
})
.collect::<Vec<ItemCargo>>();

let (start, end) = (
((page - 1) * posts_per_page) as usize,
(page * posts_per_page) as usize,
);

let items = match filtered_items_and_cargo.len() {
x if x > end => filtered_items_and_cargo[start..end].to_vec(),
x if x < end => filtered_items_and_cargo[start..].to_vec(),
let items = match merged_items_and_cargo.len() {
x if x > end => merged_items_and_cargo[start..end].to_vec(),
x if x < end => merged_items_and_cargo[start..].to_vec(),
_ => vec![],
};

Expand All @@ -147,9 +98,9 @@ pub(crate) async fn list_items_and_cargo(
tiers: merged_tiers,
tags: merged_tags,
per_page: posts_per_page,
total: filtered_items_and_cargo.len() as u64,
total: merged_items_and_cargo.len() as u64,
page,
pages: filtered_items_and_cargo.len() as u64 / posts_per_page,
pages: merged_items_and_cargo.len() as u64 / posts_per_page,
}))
}

Expand Down
Loading

0 comments on commit 2a9bc62

Please sign in to comment.