Skip to content

Commit

Permalink
Add join date to activity report tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Celeo committed Oct 24, 2024
1 parent 261b4c6 commit d274db9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
15 changes: 9 additions & 6 deletions vzdv-site/src/endpoints/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use axum::{
routing::{delete, get, post},
Form, Router,
};
use chrono::{Months, Utc};
use chrono::{DateTime, Months, Utc};
use log::{debug, error, info, warn};
use minijinja::{context, Environment};
use reqwest::StatusCode;
Expand Down Expand Up @@ -789,9 +789,10 @@ async fn page_activity_report_generate(
session: Session,
) -> Result<Response, AppError> {
#[derive(Serialize)]
struct CidAndName {
struct BasicInfo {
cid: u32,
name: String,
join_date: Option<DateTime<Utc>>,
home: bool,
minutes_online: u32,
}
Expand Down Expand Up @@ -842,13 +843,13 @@ async fn page_activity_report_generate(
acc
});

let rated_violations: Vec<CidAndName> = controllers
let rated_violations: Vec<BasicInfo> = controllers
.iter()
.filter(|controller| {
controller.rating > ControllerRating::OBS.as_id()
&& activity_map.get(&controller.cid).unwrap_or(&0) < &180
})
.map(|controller| CidAndName {
.map(|controller| BasicInfo {
cid: controller.cid,
name: format!(
"{} {} ({})",
Expand All @@ -859,12 +860,13 @@ async fn page_activity_report_generate(
None => "??",
}
),
join_date: controller.join_date,
home: controller.home_facility == "ZDV",
minutes_online: *activity_map.get(&controller.cid).unwrap_or(&0),
})
.collect();

let mut unrated_violations: Vec<CidAndName> = Vec::new();
let mut unrated_violations: Vec<BasicInfo> = Vec::new();
for controller in &controllers {
if controller.rating != ControllerRating::OBS.as_id() {
continue;
Expand All @@ -883,7 +885,7 @@ async fn page_activity_report_generate(
}
};
if records.is_empty() {
unrated_violations.push(CidAndName {
unrated_violations.push(BasicInfo {
cid: controller.cid,
name: format!(
"{} {} ({})",
Expand All @@ -894,6 +896,7 @@ async fn page_activity_report_generate(
None => "??",
}
),
join_date: controller.join_date,
home: controller.home_facility == "ZDV",
minutes_online: 0,
});
Expand Down
4 changes: 4 additions & 0 deletions vzdv-site/templates/admin/activity_report.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<tr>
<th>Name</th>
<th>Type</th>
<th>Join date</th>
<th>Hours on scope</th>
<th></th>
</tr>
Expand All @@ -13,6 +14,7 @@
<tr>
<td>{{ controller.name }}</td>
<td>{% if controller.home %}Home{% else %}Visiting{% endif %}</td>
<td>{{ controller.join_date }}</td>
<td>{{ controller.minutes_online|minutes_to_hm }}</td>
<td>
<a href="/controller/{{ controller.cid }}" class="icon-link icon-link-hover text-decoration-none">
Expand All @@ -30,6 +32,7 @@
<tr>
<th>Name</th>
<th>Type</th>
<th>Join date</th>
<th></th>
</tr>
</thead>
Expand All @@ -38,6 +41,7 @@
<tr>
<td>{{ controller.name }}</td>
<td>{% if controller.home %}Home{% else %}Visiting{% endif %}</td>
<td>{{ controller.join_date }}</td>
<td>
<a href="/controller/{{ controller.cid }}" class="icon-link icon-link-hover text-decoration-none">
<i class="bi bi-arrow-right-short"></i>
Expand Down
1 change: 1 addition & 0 deletions vzdv-site/templates/changelog.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<div class="card-text">
<ul>
<li>Privacy policy page added.</li>
<li>Small changes to activity report.</li>
</ul>
</div>
</div>
Expand Down

0 comments on commit d274db9

Please sign in to comment.