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

Commit

Permalink
changes resource planning logic to handle one day at a time, saving i…
Browse files Browse the repository at this point in the history
…ntermediate results to db
  • Loading branch information
dvalnn committed May 13, 2024
1 parent 5f17b71 commit d57e9ef
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 171 deletions.
4 changes: 2 additions & 2 deletions src/db_api/pieces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl RawMaterial {
pub async fn get_net_requirements(
&self,
con: &mut PgConnection,
) -> sqlx::Result<HashMap<i32, i32>> {
) -> sqlx::Result<BTreeMap<i32, i32>> {
Ok(sqlx::query!(
r#"
SELECT COUNT(items.id) as quantity, transformations.date as date
Expand All @@ -93,7 +93,7 @@ impl RawMaterial {
.fetch_all(con)
.await?
.into_iter()
.fold(HashMap::new(), |mut map, row| {
.fold(BTreeMap::new(), |mut map, row| {
map.insert(
row.date.expect("selecting only non null"),
row.quantity.expect("selecting only non null") as i32,
Expand Down
Loading

0 comments on commit d57e9ef

Please sign in to comment.