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

Commit

Permalink
typos: Corrected shippment -> shipment
Browse files Browse the repository at this point in the history
typos: Corrected shippment -> shipment
  • Loading branch information
dvalnn committed Apr 28, 2024
1 parent f871101 commit e48ee2b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/db_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod items;
mod orders;
mod pieces;
mod recipes;
mod shippments;
mod shipments;
mod suppliers;
mod transformations;

Expand All @@ -16,7 +16,7 @@ pub use items::*;
pub use orders::*;
pub use pieces::*;
pub use recipes::*;
pub use shippments::*;
pub use shipments::*;
pub use suppliers::*;
pub use transformations::*;

Expand Down
8 changes: 4 additions & 4 deletions src/db_api/shippments.rs → src/db_api/shipments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use uuid::Uuid;
use super::RawMaterial;

#[derive(Debug)]
pub struct Shippment {
pub struct Shipment {
id: Option<i64>,
supplier_id: i64,
request_date: i32,
Expand All @@ -26,7 +26,7 @@ pub struct ExpectedShippment {
pub quantity: i32,
}

impl Shippment {
impl Shipment {
pub fn new(
supplier_id: i64,
request_date: i32,
Expand Down Expand Up @@ -114,9 +114,9 @@ impl Shippment {
arrival_date: i32,
current_date: i32,
con: &mut PgConnection,
) -> sqlx::Result<Option<Shippment>> {
) -> sqlx::Result<Option<Shipment>> {
sqlx::query_as!(
Shippment,
Shipment,
r#"
SELECT
ship.id,
Expand Down
6 changes: 3 additions & 3 deletions src/db_api/suppliers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use sqlx::postgres::types::PgMoney;
use sqlx::PgConnection;
use uuid::Uuid;

use super::{RawMaterial, Shippment};
use super::{RawMaterial, Shipment};

#[derive(Debug, Clone)]
pub struct Supplier {
Expand All @@ -20,10 +20,10 @@ impl Supplier {
self.delivery_time <= time
}

pub fn shippment(&self, order_quantity: i32, due_date: i32) -> Shippment {
pub fn shippment(&self, order_quantity: i32, due_date: i32) -> Shipment {
let quantity = order_quantity.max(self.min_order_quantity);
let cost = quantity as i64 * self.unit_price.0;
Shippment::new(
Shipment::new(
self.id,
due_date - self.delivery_time,
quantity,
Expand Down
20 changes: 10 additions & 10 deletions src/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use uuid::Uuid;

use crate::{
db_api::{
Item, Order, OrderStatus, RawMaterial, Shippment, Transformation,
Item, Order, OrderStatus, RawMaterial, Shipment, Transformation,
TransformationDetails,
},
scheduler::{Scheduler, CURRENT_DATE},
Expand Down Expand Up @@ -323,13 +323,13 @@ pub async fn post_warehouse_action(

#[derive(Debug, Deserialize, Serialize)]
struct ExpectedShipmentForm {
shippment_id: i64,
shipment_id: i64,
material_type: RawMaterial,
quantity: i32,
}

#[get("/materials/expected")]
pub async fn get_expected_shippments(
pub async fn get_expected_shipments(
query: Query<DayForm>,
pool: Data<PgPool>,
) -> impl Responder {
Expand All @@ -339,12 +339,12 @@ pub async fn get_expected_shippments(
};

let expected =
Shippment::get_expected_for_arrival(query.day as i32, &mut con);
Shipment::get_expected_for_arrival(query.day as i32, &mut con);
let response_body = match expected.await {
Ok(shipp_vec) => shipp_vec
.iter()
.map(|s| ExpectedShipmentForm {
shippment_id: s.id,
shipment_id: s.id,
material_type: s.material_type,
quantity: s.quantity,
})
Expand All @@ -357,21 +357,21 @@ pub async fn get_expected_shippments(

#[derive(Debug, Deserialize)]
#[cfg_attr(test, derive(serde::Serialize))]
struct ShippmentArrivalForm {
shippment_id: i64,
struct ShipmentArrivalForm {
shipment_id: i64,
}

#[post("/materials/arrivals")]
pub async fn post_material_arrival(
form: Form<ShippmentArrivalForm>,
form: Form<ShipmentArrivalForm>,
pool: Data<PgPool>,
) -> impl Responder {
let date = Scheduler::get_date() as i32;

match Shippment::arrived(form.shippment_id, date, &pool).await {
match Shipment::arrived(form.shipment_id, date, &pool).await {
Err(e) => internal_server_error(e),
Ok(_) => {
tracing::info!("Shippment {} arrived", form.shippment_id);
tracing::info!("Shippment {} arrived", form.shipment_id);
HttpResponse::Created().finish()
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/scheduler/resource_planning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use std::collections::HashMap;
use sqlx::PgPool;

use crate::db_api::{
MaterialShippment, RawMaterial, Shippment, Supplier,
UnderAllocatedShippment,
MaterialShippment, RawMaterial, Shipment, Supplier, UnderAllocatedShippment,
};

use super::Scheduler;
Expand Down Expand Up @@ -104,7 +103,7 @@ pub async fn resolve_material_needs(
}

struct PurchaseProcessingResults {
pub purchase_orders_by_due_date: HashMap<i32, Shippment>,
pub purchase_orders_by_due_date: HashMap<i32, Shipment>,
pub altered_shippments_by_due_date: HashMap<i32, Vec<AlteredShippment>>,
}

Expand Down Expand Up @@ -239,7 +238,7 @@ async fn query_needed_data(
let mut shippment_map = HashMap::new();
for day in net_req.keys() {
let shippments =
Shippment::get_under_allocated(*day, variant, &mut conn).await?;
Shipment::get_under_allocated(*day, variant, &mut conn).await?;
if !shippments.is_empty() {
shippment_map.insert(*day, shippments);
}
Expand Down
2 changes: 1 addition & 1 deletion src/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl App {
.service(routes::get_production)
.service(routes::post_transformation_completion)
.service(routes::post_warehouse_action)
.service(routes::get_expected_shippments)
.service(routes::get_expected_shipments)
.service(routes::post_material_arrival)
.service(routes::get_deliveries)
.app_data(Data::new(self.pool.clone()))
Expand Down

0 comments on commit e48ee2b

Please sign in to comment.