Solved: Big world test
This commit is contained in:
parent
52f92969b5
commit
3178c07f84
2 changed files with 26 additions and 16 deletions
|
|
@ -198,6 +198,7 @@ impl Handler {
|
|||
ClientFrames::IAmCamera { road, mile, limit } => {
|
||||
info!("Receive new camera: {road} at {mile} with limit {limit}");
|
||||
if self.connection_type.is_some() {
|
||||
let _ = send_message.send(ServerFrames::Error { msg: "Already connected as camera".to_string() }).await;
|
||||
return Err("Already connected".into());
|
||||
}
|
||||
self.set_connection_type(ConnectionType::Camera);
|
||||
|
|
@ -213,6 +214,7 @@ impl Handler {
|
|||
}
|
||||
ClientFrames::IAmDispatcher { roads } => {
|
||||
if self.connection_type.is_some() {
|
||||
let _ = send_message.send(ServerFrames::Error { msg: "Already connected as dispatcher".to_string() }).await;
|
||||
return Err("Already connected".into());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,25 +51,33 @@ pub(crate) async fn issue_possible_ticket(db: Arc<Mutex<Db>>, plate: Plate, came
|
|||
let day_start = timestamp1 / 86400;
|
||||
let day_end = timestamp2 / 86400;
|
||||
|
||||
|
||||
let spans_multiple_days = day_start != day_end;
|
||||
|
||||
if spans_multiple_days && (db.is_plate_ticketed_for_day(day_start, plate_name.clone()) || db.is_plate_ticketed_for_day(day_end, plate_name.clone())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if db.is_plate_ticketed_for_day(day_start, plate_name.clone()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for day in day_start..=day_end {
|
||||
info!("Day {day} for {ticket:?}");
|
||||
if db.is_plate_ticketed_for_day(day, plate_name.clone()) {
|
||||
info!("Ticket already issued: {ticket:?}");
|
||||
continue;
|
||||
}
|
||||
|
||||
info!("Ticket for day {day} for {ticket:?}");
|
||||
db.ticket_plate(day, plate_name.clone());
|
||||
let dispatcher = db.get_dispatcher_for_road(road.clone());
|
||||
|
||||
if dispatcher.is_none() {
|
||||
info!("No dispatcher yet for this road: {ticket:?}");
|
||||
db.add_open_ticket(ticket.clone());
|
||||
continue;
|
||||
}
|
||||
|
||||
info!("Sending ticket: {ticket:?}");
|
||||
let _ = dispatcher.unwrap().send(ticket.clone().into()).await;
|
||||
}
|
||||
|
||||
let dispatcher = db.get_dispatcher_for_road(road.clone());
|
||||
|
||||
if dispatcher.is_none() {
|
||||
info!("No dispatcher yet for this road: {ticket:?}");
|
||||
db.add_open_ticket(ticket.clone());
|
||||
continue;
|
||||
}
|
||||
|
||||
info!("Sending ticket: {ticket:?}");
|
||||
let _ = dispatcher.unwrap().send(ticket.clone().into()).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue