mirror of
https://github.com/zzzzDev4/ias-tea-axum.git
synced 2025-04-21 07:41:21 +02:00
added retrieve_brewing_events_by_tea_id
This commit is contained in:
parent
ddebe1d81f
commit
d90f2db9d8
2 changed files with 23 additions and 0 deletions
|
@ -29,6 +29,8 @@ async fn main(#[shuttle_shared_db::Postgres] pool: PgPool) -> shuttle_axum::Shut
|
||||||
.route("/configuration", put(update_config))
|
.route("/configuration", put(update_config))
|
||||||
// brewing events
|
// brewing events
|
||||||
.route("/brewing-events", get(retrieve_brewing_events))
|
.route("/brewing-events", get(retrieve_brewing_events))
|
||||||
|
// brewing events by id
|
||||||
|
.route("/brewing-events/:id", get(retrieve_brewing_events_by_tea_id))
|
||||||
// types of tea (update tea metadata, no log entry for steeping time)
|
// types of tea (update tea metadata, no log entry for steeping time)
|
||||||
.route("/types-of-tea", get(retrieve_types_of_tea))
|
.route("/types-of-tea", get(retrieve_types_of_tea))
|
||||||
.route("/types-of-tea/:id", put(update_tea_meta_by_id))
|
.route("/types-of-tea/:id", put(update_tea_meta_by_id))
|
||||||
|
|
|
@ -62,6 +62,27 @@ pub async fn retrieve_brewing_events(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn retrieve_brewing_events_by_tea_id(
|
||||||
|
Path(id): Path<i32>,
|
||||||
|
State(state): State<MyState>,
|
||||||
|
) -> Result<impl IntoResponse, impl IntoResponse> {
|
||||||
|
match sqlx::query_as::<_, SteepingLog>(
|
||||||
|
"
|
||||||
|
SELECT *
|
||||||
|
FROM steepinglog
|
||||||
|
WHERE id = $1
|
||||||
|
ORDER BY steeping_tested_time
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.bind(id)
|
||||||
|
.fetch_all(&state.pool)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(steeping_log) => Ok((StatusCode::OK, Json(steeping_log))),
|
||||||
|
Err(e) => Err((StatusCode::BAD_REQUEST, e.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// used by teavail-device
|
// used by teavail-device
|
||||||
pub async fn retrieve_tea_by_rfid(
|
pub async fn retrieve_tea_by_rfid(
|
||||||
Path(rfid): Path<String>,
|
Path(rfid): Path<String>,
|
||||||
|
|
Loading…
Add table
Reference in a new issue