fix: adjust class year, filter out unexpected weekdays and ignore useless CSV rows
This commit is contained in:
parent
4524d84ab9
commit
98e1d31e13
@ -171,12 +171,7 @@ pub async fn get_class(Query(params): Query<FilterByClassQuery>) -> impl IntoRes
|
|||||||
for record in rdr.records() {
|
for record in rdr.records() {
|
||||||
let record = match record {
|
let record = match record {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(_) => {
|
Err(_) => continue,
|
||||||
return (
|
|
||||||
StatusCode::UNPROCESSABLE_ENTITY,
|
|
||||||
Json(json!({ "errore": "Formato non supportato"})),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
for (i, cell) in record.iter().enumerate() {
|
for (i, cell) in record.iter().enumerate() {
|
||||||
if cell == params.classe {
|
if cell == params.classe {
|
||||||
|
@ -54,7 +54,7 @@ function load_classes(id) {
|
|||||||
}
|
}
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
const option = document.createElement("option");
|
const option = document.createElement("option");
|
||||||
option.value = i;
|
option.value = i + 1;
|
||||||
option.text = i + 1;
|
option.text = i + 1;
|
||||||
select.appendChild(option);
|
select.appendChild(option);
|
||||||
}
|
}
|
||||||
@ -87,12 +87,14 @@ function make_teacher_table(id, teacher) {
|
|||||||
th.scope = "row";
|
th.scope = "row";
|
||||||
th.textContent = weekday;
|
th.textContent = weekday;
|
||||||
tr.appendChild(th);
|
tr.appendChild(th);
|
||||||
|
if (data[weekday] != null) {
|
||||||
data[weekday].forEach((teacher_class) => {
|
data[weekday].forEach((teacher_class) => {
|
||||||
let td = document.createElement("td");
|
let td = document.createElement("td");
|
||||||
td.textContent = teacher_class;
|
td.textContent = teacher_class;
|
||||||
tr.appendChild(td);
|
tr.appendChild(td);
|
||||||
});
|
});
|
||||||
tbody.appendChild(tr);
|
tbody.appendChild(tr);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
table.appendChild(tbody);
|
table.appendChild(tbody);
|
||||||
document.getElementById("table").removeAttribute("aria-busy");
|
document.getElementById("table").removeAttribute("aria-busy");
|
||||||
@ -123,12 +125,14 @@ function make_student_table(id, student_class) {
|
|||||||
th.scope = "row";
|
th.scope = "row";
|
||||||
th.textContent = weekday;
|
th.textContent = weekday;
|
||||||
tr.appendChild(th);
|
tr.appendChild(th);
|
||||||
|
if (data[weekday] != null) {
|
||||||
data[weekday].forEach((student_class) => {
|
data[weekday].forEach((student_class) => {
|
||||||
let td = document.createElement("td");
|
let td = document.createElement("td");
|
||||||
td.textContent = student_class;
|
td.textContent = student_class;
|
||||||
tr.appendChild(td);
|
tr.appendChild(td);
|
||||||
});
|
});
|
||||||
tbody.appendChild(tr);
|
tbody.appendChild(tr);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
table.appendChild(tbody);
|
table.appendChild(tbody);
|
||||||
document.getElementById("table").removeAttribute("aria-busy");
|
document.getElementById("table").removeAttribute("aria-busy");
|
||||||
@ -168,7 +172,7 @@ function load_section() {
|
|||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Object.keys(data[year]).forEach((el) => {
|
Object.keys(data[year - 1]).forEach((el) => {
|
||||||
const option = document.createElement("option");
|
const option = document.createElement("option");
|
||||||
option.value = el;
|
option.value = el;
|
||||||
option.text = el;
|
option.text = el;
|
||||||
@ -187,7 +191,7 @@ function load_major() {
|
|||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data[year][section].forEach((el) => {
|
data[year - 1][section].forEach((el) => {
|
||||||
const option = document.createElement("option");
|
const option = document.createElement("option");
|
||||||
option.value = el;
|
option.value = el;
|
||||||
option.text = el;
|
option.text = el;
|
||||||
|
Loading…
Reference in New Issue
Block a user