fix: make sure batch event is start

This commit is contained in:
imlonghao 2022-01-23 18:57:15 +08:00
parent 21d46e2437
commit 3fa0610b51
2 changed files with 6 additions and 6 deletions

View file

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
- Change SQL to make sure batch event is `start`
### Removed
- Remove `Courier` from font-family

View file

@ -19,7 +19,7 @@ code {
}
</style>"#;
#[derive(Debug, ToSql, FromSql, Display, PartialEq)]
#[derive(Debug, ToSql, FromSql, Display)]
#[postgres(name = "batchevent")]
enum BatchEvent {
#[postgres(name = "start")]
@ -233,15 +233,11 @@ async fn get_pkg_log(
let conn = db.get().await.unwrap();
let rows = conn
.query(
"select * from lilac.batch where ts < $1 order by id desc limit 1",
"select logdir from lilac.batch where ts < $1 and event = 'start' order by id desc limit 1",
&[&dt],
)
.await
.unwrap();
let event: BatchEvent = rows[0].get("event");
if event != BatchEvent::Start {
return HttpResponse::BadRequest().body("wrong time");
}
let logdir: String = rows[0].get("logdir");
let contents =
std::fs::read_to_string(format!("/home/lilydjwg/.lilac/log/{}/{}.log", logdir, name))