refactor(timesheet): use repeat() for separator lines and sort points before grouping
All checks were successful
Continuous Integration / Build Package (push) Successful in 25s
Continuous Integration / Lint, Check & Test (push) Successful in 41s

This commit is contained in:
Konstantin Fickel 2026-04-02 17:07:36 +02:00
parent b51fb511ac
commit d11a35c157
Signed by: kfickel
GPG key ID: A793722F9933C1A5
2 changed files with 17 additions and 19 deletions

View file

@ -136,8 +136,12 @@ fn aggregate_timecard_day(points: &[TimesheetPoint]) -> Result<Option<Timesheet>
fn aggregate_timecards(points: &[TimesheetPoint]) -> Result<Vec<Timesheet>, StreamdError> {
let mut timesheets = Vec::new();
// Sort points by moment to ensure proper grouping
let mut sorted_points = points.to_vec();
sorted_points.sort_by_key(|p| p.moment);
// Group by date
for (_date, group) in &points.iter().chunk_by(|p| p.moment.date_naive()) {
for (_date, group) in &sorted_points.iter().chunk_by(|p| p.moment.date_naive()) {
let day_points: Vec<_> = group.cloned().collect();
if let Some(timesheet) = aggregate_timecard_day(&day_points)? {
timesheets.push(timesheet);