diff --git a/Dockerfile copy b/Dockerfile copy deleted file mode 100644 index b8f64fe..0000000 --- a/Dockerfile copy +++ /dev/null @@ -1,16 +0,0 @@ -FROM rust:latest AS builder -WORKDIR /app -COPY . . -RUN cargo build --release - -FROM debian:bookworm-slim -WORKDIR /app -COPY --from=builder /app/target/release/hotel-api-rs /usr/local/bin/hotel-api-rs - -# Create the directory where DB will be stored -RUN mkdir -p /db - -# Expose API port -EXPOSE 8080 - -CMD ["/usr/local/bin/hotel-api-rs"] \ No newline at end of file diff --git a/db/1.sqlite b/db/1.sqlite index 663bc98..9dad92e 100644 Binary files a/db/1.sqlite and b/db/1.sqlite differ diff --git a/db/1.sqlite-shm b/db/1.sqlite-shm new file mode 100644 index 0000000..1168272 Binary files /dev/null and b/db/1.sqlite-shm differ diff --git a/db/1.sqlite-wal b/db/1.sqlite-wal new file mode 100644 index 0000000..715afd3 Binary files /dev/null and b/db/1.sqlite-wal differ diff --git a/db/auth_copy_2.sqlite b/db/auth_copy_2.sqlite index e2bd687..036d95c 100644 Binary files a/db/auth_copy_2.sqlite and b/db/auth_copy_2.sqlite differ diff --git a/db/auth_copy_2.sqlite-shm b/db/auth_copy_2.sqlite-shm new file mode 100644 index 0000000..91140f8 Binary files /dev/null and b/db/auth_copy_2.sqlite-shm differ diff --git a/db/auth_copy_2.sqlite-wal b/db/auth_copy_2.sqlite-wal new file mode 100644 index 0000000..d767ff7 Binary files /dev/null and b/db/auth_copy_2.sqlite-wal differ diff --git a/hotel_1.sqlite b/hotel_1.sqlite deleted file mode 100644 index e69de29..0000000 diff --git a/hotel_schema.sql b/hotel_schema.sql deleted file mode 100644 index e69de29..0000000 diff --git a/refrech_token.sql b/refrech_token.sql deleted file mode 100644 index 6adcce2..0000000 --- a/refrech_token.sql +++ /dev/null @@ -1,6 +0,0 @@ -id INT - user_id INTEGER NOT NULL, - token_hash TEXT NOT NULL, - device_id TEXT NOT NULL, - user_agent TEXT NOT NULL, - hotel_id TEXT \ No newline at end of file diff --git a/rust-api-1-0-2.tar b/rust-api-1-0-2.tar deleted file mode 100644 index b376aac..0000000 Binary files a/rust-api-1-0-2.tar and /dev/null differ diff --git a/rust-api-1-0-3.tar b/rust-api-1-0-3.tar deleted file mode 100644 index c3e4ff3..0000000 Binary files a/rust-api-1-0-3.tar and /dev/null differ diff --git a/rust-api-1-0-4.tar b/rust-api-1-0-4.tar deleted file mode 100644 index a11c6fc..0000000 Binary files a/rust-api-1-0-4.tar and /dev/null differ diff --git a/src/inventory/handler.rs b/src/inventory/handler.rs index 3164ad7..09e06ed 100644 --- a/src/inventory/handler.rs +++ b/src/inventory/handler.rs @@ -74,6 +74,24 @@ pub async fn update_inventory_item( ){ return (StatusCode::INTERNAL_SERVER_ERROR, format!("failed to update inventory history")); } + + if let Some(hotel_users) = state.ws_map.get(&hotel_id) { + let update_msg = json!({ + "event_type": "item_update", + "item_id": item_id, + "number": item_amount, + "updated_by": user_id, + }) + .to_string(); + + for entry in hotel_users.iter() { + let sender = entry.value(); + // ignore errors (client disconnected) + let _ = sender.send(Message::Text(update_msg.clone().into())); + } + } + + (StatusCode::OK, format!("updated item history")) } @@ -82,6 +100,9 @@ pub async fn update_inventory_item( } + + + /* match result { Ok(row) => (StatusCode::OK, format!("Items updated")),