Skip to content

Commit

Permalink
clippy, makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
djkato committed Jan 3, 2025
1 parent 4b8ff98 commit 9b3e4f0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
11 changes: 11 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ PKG_VER=$(cargo pkgid --package=sitemap-generator | cut -d "#" -f2)
docker build --rm --target chef-sitemap-generator . -t ghcr.io/djkato/saleor-app-sitemap-generator:${PKG_VER}
'''

[tasks.build-bulk-price-manipulator]
workspace = false
script = '''
PKG_VER=$(cargo pkgid --package=bulk-price-manipulator | cut -d "#" -f2)
docker build --rm --target chef-bulk-price-manipulator . -t ghcr.io/djkato/saleor-app-bulk-price-generator:${PKG_VER}
'''


[tasks.build-simple-payment-gateway]
workspace = false
script = '''
Expand All @@ -26,18 +34,21 @@ dependencies = [
"delete-images",
"build-sitemap-generator",
"build-simple-payment-gateway",
"build-bulk-price-manipulator",
]

[tasks.push-containers]
workspace = false
script = '''
docker push ghcr.io/djkato/saleor-app-sitemap-generator:latest
docker push ghcr.io/djkato/saleor-app-simple-payment-gateway:latest
docker push ghcr.io/djkato/saleor-app-bulk-price-generator:latest
'''

[tasks.delete-images]
workspace = false
script = '''
docker rmi -f $(docker image ls -q --filter=label=service=chef-sitemap-generator) 2>&1 || true
docker rmi -f $(docker image ls -q --filter=label=service=chef-simple-payment-gateway) 2>&1 || true
docker rmi -f $(docker image ls -q --filter=label=service=chef-bulk-price-manipulator) 2>&1 || true
'''
21 changes: 9 additions & 12 deletions bulk-price-manipulator/src/updater/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ async fn set_variant_price(
let operation = UpdatePrice::build(UpdatePriceVariables {
channel,
variant,
cost_price: cost_price
.and_then(|d| Some(PositiveDecimal(Decimal::from_f32(d).unwrap().round_dp(2)))),
cost_price: cost_price.map(|d| PositiveDecimal(Decimal::from_f32(d).unwrap().round_dp(2))),
price: PositiveDecimal(Decimal::from_f64(price).unwrap().round_dp(2)),
});
// dbg!(&operation.query, &operation.variables);
Expand Down Expand Up @@ -257,8 +256,7 @@ pub fn create_context_map(
.as_ref()
.and_then(|p| {
p.price_undiscounted
.as_ref()
.and_then(|n| Some(n.net.currency.clone()))
.as_ref().map(|n| n.net.currency.clone())
})
.unwrap_or("".into()),
),
Expand All @@ -269,7 +267,7 @@ pub fn create_context_map(
variant
.pricing
.as_ref()
.and_then(|p| p.price.as_ref().and_then(|n| Some(n.gross.amount.clone())))
.and_then(|p| p.price.as_ref().and_then(|n| Some(n.gross.amount)))
.unwrap_or(0.),
),
)?;
Expand All @@ -279,7 +277,7 @@ pub fn create_context_map(
variant
.pricing
.as_ref()
.and_then(|p| p.price.as_ref().and_then(|n| Some(n.net.amount.clone())))
.and_then(|p| p.price.as_ref().and_then(|n| Some(n.net.amount)))
.unwrap_or(0.),
),
)?;
Expand All @@ -289,7 +287,7 @@ pub fn create_context_map(
variant
.pricing
.as_ref()
.and_then(|p| p.price.as_ref().and_then(|n| Some(n.tax.amount.clone())))
.and_then(|p| p.price.as_ref().and_then(|n| Some(n.tax.amount)))
.unwrap_or(0.),
),
)?;
Expand All @@ -313,7 +311,7 @@ pub fn create_context_map(
.and_then(|c| {
c.iter()
.find(|c| c.id.inner() == current_channel_id)
.and_then(|c| c.price.as_ref().and_then(|p| Some(p.amount)))
.and_then(|c| c.price.as_ref().map(|p| p.amount))
})
.unwrap_or(0.),
),
Expand All @@ -327,7 +325,7 @@ pub fn create_context_map(
.and_then(|c| {
c.iter()
.find(|c| c.id.inner() == current_channel_id)
.and_then(|c| c.cost_price.as_ref().and_then(|p| Some(p.amount)))
.and_then(|c| c.cost_price.as_ref().map(|p| p.amount))
})
.unwrap_or(0.),
),
Expand All @@ -341,7 +339,7 @@ pub fn create_context_map(
.and_then(|c| {
c.iter()
.find(|c| c.id.inner() == current_channel_id)
.and_then(|c| c.price.as_ref().and_then(|p| Some(p.currency.clone())))
.and_then(|c| c.price.as_ref().map(|p| p.currency.clone()))
})
.unwrap_or("".into()),
),
Expand All @@ -355,8 +353,7 @@ pub fn create_context_map(
.as_ref()
.and_then(|v| {
v.price_undiscounted
.as_ref()
.and_then(|t| Some(t.net.amount))
.as_ref().map(|t| t.net.amount)
})
.unwrap_or(0.),
),
Expand Down

0 comments on commit 9b3e4f0

Please sign in to comment.