refactor(timesheet): use repeat() for separator lines and sort points before grouping
This commit is contained in:
parent
b51fb511ac
commit
d11a35c157
2 changed files with 17 additions and 19 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue