Add feature to import missing schedules
This commit is contained in:
parent
6400b7745c
commit
c8f40284ef
6 changed files with 81 additions and 26 deletions
emgauwa-lib/src/db
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue