Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into nutrition/app
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKutschera committed Apr 20, 2024
2 parents 19f1e4c + 67b3b7d commit a447fe4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 30 deletions.
4 changes: 4 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ The following options are available:
| `RATE_LIMIT` | Limit the number of API requests per second. `0` means disabled. | `0` (disabled) |
| `MAX_UPLOAD_SIZE` | Maximal size (in bytes) an http body can have to get accepted. This implies a maximal size an image upload can have. | `10485760` (10 MiB) |

### Notes
- The **timezone** of log messages and the chron schedule is only queried once at backend startup from the host os because of technical limitations. For changes in timezone (e.g. summer time) the server has to be restarted.



## Building the backend

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ mod test {
assert!(450.0 < average);
assert!(460.0 > average);

let dishes = vec![];
let dishes = [];
let average = RelationResolver::<MealplanManagementDatabaseMock>::average(dishes.iter());
assert!((average - 0.0).abs() < f64::EPSILON);
}
Expand Down
64 changes: 35 additions & 29 deletions backend/src/layer/trigger/scheduling/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,28 @@ impl Scheduler {
// === mensa parsing ===

let mensa_parse = Arc::new(parse_scheduling);
let timezone = chrono::Local::now().timezone();

// mensa update parsing
let mensa_parse_update = mensa_parse.clone();
let update_parse_job = Job::new_async(info.update_parse_schedule.as_ref(), move |_, _| {
let mensa_parse = mensa_parse_update.clone();
Box::pin(
async move {
info!("Started mensa update parsing.");
let start: Instant = Instant::now();

mensa_parse.start_update_parsing().await;

info!("Finished mensa update parsing in {:?}.", start.elapsed());
}
.instrument(info_span!("update_parsing")),
)
})
let update_parse_job = Job::new_async_tz(
info.update_parse_schedule.as_ref(),
timezone,
move |_, _| {
let mensa_parse = mensa_parse_update.clone();
Box::pin(
async move {
info!("Started mensa update parsing.");
let start: Instant = Instant::now();

mensa_parse.start_update_parsing().await;

info!("Finished mensa update parsing in {:?}.", start.elapsed());
}
.instrument(info_span!("update_parsing")),
)
},
)
.expect("could not create schedule for image reviewing");

scheduler
Expand All @@ -73,21 +78,22 @@ impl Scheduler {
.expect("could not add job for update parsing to scheduler");

// mensa full parsing
let full_parse_job = Job::new_async(info.full_parse_schedule.as_ref(), move |_, _| {
let mensa_parse = mensa_parse.clone();
Box::pin(
async move {
info!("Started mensa full parsing.");
let start: Instant = Instant::now();

mensa_parse.start_full_parsing().await;

info!("Finished mensa full parsing in {:?}.", start.elapsed());
}
.instrument(info_span!("full_parsing")),
)
})
.expect("could not create schedule for image reviewing");
let full_parse_job =
Job::new_async_tz(info.full_parse_schedule.as_ref(), timezone, move |_, _| {
let mensa_parse = mensa_parse.clone();
Box::pin(
async move {
info!("Started mensa full parsing.");
let start: Instant = Instant::now();

mensa_parse.start_full_parsing().await;

info!("Finished mensa full parsing in {:?}.", start.elapsed());
}
.instrument(info_span!("full_parsing")),
)
})
.expect("could not create schedule for image reviewing");

scheduler
.add(full_parse_job)
Expand Down

0 comments on commit a447fe4

Please sign in to comment.