feat: added a side bar
This commit is contained in:
@@ -75,7 +75,7 @@ func ReportsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
"ShowAdminNav": role == 1,
|
||||
"ShowVolunteerNav": role != 1,
|
||||
"UserName": username,
|
||||
"ActiveSection": "reports",
|
||||
"ActiveSection": "reports",
|
||||
"Category": category,
|
||||
"ReportID": reportID,
|
||||
"DateFrom": dateFrom,
|
||||
@@ -177,20 +177,23 @@ func getAllReportDefinitions() map[string][]ReportDefinition {
|
||||
return map[string][]ReportDefinition{
|
||||
"users": {
|
||||
{
|
||||
ID: "users_by_role",
|
||||
Name: "Users by Role",
|
||||
ID: "volunteer_participation_rate", // get all the appointment(done, notdone, total) poll(done, not doen, total)
|
||||
Name: "Volunteer participation rate",
|
||||
Description: "Count of users grouped by their role",
|
||||
SQL: `SELECT
|
||||
CASE
|
||||
WHEN role_id = 1 THEN 'Admin'
|
||||
WHEN role_id = 2 THEN 'Volunteer'
|
||||
ELSE 'Unknown'
|
||||
END as role,
|
||||
COUNT(*) as user_count,
|
||||
COUNT(CASE WHEN created_at >= ?1 THEN 1 END) as new_this_period
|
||||
FROM users
|
||||
GROUP BY role_id
|
||||
ORDER BY role_id`,
|
||||
u.user_id,
|
||||
u.first_name,
|
||||
u.last_name,
|
||||
COUNT(p.poll_id) AS total_polls,
|
||||
COUNT(a.user_id) AS total_appointments,
|
||||
case
|
||||
WHEN COUNT(a.user_id) = 0 THEN NULL -- avoid division by zero
|
||||
ELSE ROUND(CAST(COUNT(p.poll_id) AS numeric) / COUNT(a.user_id), 2)
|
||||
END AS poll_to_appointment_rate
|
||||
from users u
|
||||
LEFT JOIN poll p ON u.user_id = p.user_id
|
||||
LEFT JOIN appointment a ON u.user_id = a.user_id
|
||||
GROUP BY u.user_id, u.first_name, u.last_name;`,
|
||||
},
|
||||
{
|
||||
ID: "volunteer_activity",
|
||||
|
||||
Reference in New Issue
Block a user