Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Fix intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Oct 10, 2024
1 parent 195e404 commit 8900a1d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/routes/internal/billing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub async fn edit_subscription(

if let Some(cancelled) = &edit_subscription.cancelled {
if open_charge.status != ChargeStatus::Open
|| open_charge.status != ChargeStatus::Cancelled
&& open_charge.status != ChargeStatus::Cancelled
{
return Err(ApiError::InvalidInput(
"You may not change the status of this subscription!".to_string(),
Expand Down Expand Up @@ -190,6 +190,8 @@ pub async fn edit_subscription(
};

Check warning on line 190 in src/routes/internal/billing.rs

View workflow job for this annotation

GitHub Actions / clippy

you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> src/routes/internal/billing.rs:178:13 | 178 | / match &current_price.prices { 179 | | Price::Recurring { intervals } => { 180 | | if let Some(price) = intervals.get(interval) { 181 | | open_charge.subscription_interval = Some(*interval); ... | 189 | | _ => {} 190 | | }; | |_____________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match = note: `#[warn(clippy::single_match)]` on by default help: try | 178 ~ if let Price::Recurring { intervals } = &current_price.prices { 179 + if let Some(price) = intervals.get(interval) { 180 + open_charge.subscription_interval = Some(*interval); 181 + open_charge.amount = *price as i64; 182 + } else { 183 + return Err(ApiError::InvalidInput( 184 + "Interval is not valid for this subscription!".to_string(), 185 + )); 186 + } 187 ~ }; |
}

open_charge.upsert(&mut transaction).await?;

transaction.commit().await?;

Ok(HttpResponse::NoContent().body(""))
Expand Down

0 comments on commit 8900a1d

Please sign in to comment.