Add feature to import missing schedules

This commit is contained in:
Tobias Reisinger 2023-11-30 02:40:28 +01:00
parent 6400b7745c
commit c8f40284ef
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
6 changed files with 81 additions and 26 deletions
emgauwa-lib/src/db

View file

@ -56,10 +56,13 @@ impl DbRelay {
controller: &DbController,
number: i64,
new_name: &str,
) -> Result<DbRelay, DatabaseError> {
) -> Result<(DbRelay, bool), DatabaseError> {
match DbRelay::get_by_controller_and_num(conn, controller, number).await? {
Some(relay) => Ok(relay),
None => DbRelay::create(conn, new_name, number, controller).await,
Some(relay) => Ok((relay, false)),
None => {
let relay = DbRelay::create(conn, new_name, number, controller).await?;
Ok((relay, true))
}
}
}