fix: export for area manager

This commit is contained in:
Max Hohlfeld 2025-06-09 18:47:16 +02:00
parent 2b9e6cfefd
commit 784b7cea4e

View File

@ -15,7 +15,7 @@ use crate::{
struct ExportQuery {
start: NaiveDate,
end: NaiveDate,
area: i32,
area: Option<i32>,
}
#[derive(PartialEq)]
@ -131,10 +131,12 @@ pub async fn get(
return Err(ApplicationError::Unauthorized);
}
let area = query.area.unwrap_or(user.area_id);
let rows_to_export = ExportEventRow::read_all_for_timerange_and_area(
pool.get_ref(),
(query.start, query.end),
query.area,
area,
)
.await?;
let entries = read(rows_to_export);
@ -154,10 +156,10 @@ pub async fn get(
"Fkt",
"Reserve",
];
worksheet.write_row(2, 0, HEADER).unwrap();
worksheet.write_row(0, 0, HEADER).unwrap();
for (i, entry) in entries.iter().enumerate() {
let i = (i + 3) as u32;
let i = (i + 1) as u32;
worksheet.write(i, 0, &entry.date).unwrap();
worksheet.write(i, 1, &entry.weekday).unwrap();