Dashboard

This section will deal with the dashboard for each project, where PM can see how much work has been done, separate tasks by labels and due dates, get heatmaps, etc.

Dashboard: Tasks Charts View

Route and Method

  • Route Name: tasks_charts

  • HTTP Method: GET

  • Renderer: Jinja2 template /templates/testing_charts.jinja2

  • Session Verification: Required (@verify_session decorator)


Purpose

Render a dashboard view that shows various aggregated and detailed statistics about tasks within a specific project, including task counts by status, tasks grouped by status with details, task label distributions by status, and task due dates distribution.


Parameters

  • Request Path Variable: project_id (int) Extracted from URL route matching dictionary (request.matchdict).


Main Logic Steps

  1. Project Retrieval

    • Fetch the project by project_id.

    • Raise HTTPNotFound if the project does not exist.

  2. Define Task Statuses and Chart Labels

    • Fixed list of task statuses:

      • 'assigned'

      • 'in_progress'

      • 'under_review'

      • 'completed'

    • Corresponding human-readable labels for charts:

      • 'Assigned'

      • 'In Progress'

      • 'Under Review'

      • 'Completed'

  3. Aggregate Task Counts by Status

    • For each status, query all active tasks of that status within the project.

    • Count the number of tasks per status.

    • Store counts in chart_data list.

    • Also prepare a dictionary tasks_by_status mapping each status (title cased, spaces instead of underscores) to a list of task summaries:

      • Task summary includes:

        • name: task title

        • due_date: formatted as 'YYYY-MM-DD' or 'Sin fecha' if no due date

  4. Aggregate Label Counts Per Status

    • For each status, query active tasks with that status.

    • For each task, retrieve associated labels (via the join table LabelsTask).

    • Count how many times each label appears for tasks of that status.

    • Store label counts per status in tasks_by_status_and_label dictionary.

  5. Get Project Labels and Their Colors

    • Query all labels associated with the project.

    • Create a dictionary label_colors mapping label names to their hex colors.

  6. Aggregate Due Dates of Tasks

    • Query all active tasks with non-null due dates in the project.

    • Extract due dates formatted as 'YYYY-MM-DD'.

    • Use Python collections.Counter to count tasks per due date.

    • Sort the counted due dates chronologically.

  7. Prepare Context for Template Rendering Return a dictionary with:

    • project: Project object

    • chart_labels: List of status labels for chart legends

    • chart_data: List of task counts per status

    • tasks_by_status_json: Dictionary mapping status to task summaries

    • tasks_by_status_and_label: Dictionary of label counts per status

    • testing_charts: Static string 'Dashboard' (likely a page identifier)

    • label_colors: Mapping of label names to hex colors

    • due_dates_labels: Sorted list of due date strings

    • due_dates_counts: Corresponding counts for each due date

    • due_dates_heatmap: Dictionary mapping due dates to counts (for heatmap visualization)

    • due_dates_heatmap_echarts: List of [date, count] pairs (for echarts heatmap consumption)


Example Data Structures

  • tasks_by_status_json:

{
  "Assigned": [
    {"name": "Task A", "due_date": "2025-06-20"},
    {"name": "Task B", "due_date": "Sin fecha"}
  ],
  "In Progress": [...],
  ...
}
  • tasks_by_status_and_label:

{
  "assigned": {"Bug": 3, "Feature": 2},
  "in_progress": {"Improvement": 5},
  ...
}
  • label_colors:

{
  "Bug": "#FF0000",
  "Feature": "#00FF00",
  "Improvement": "#0000FF"
}
  • due_dates_heatmap_echarts:

[
  ["2025-06-20", 3],
  ["2025-06-21", 5],
  ...
]

Notes

  • All task queries filter for Task.active == True ensuring only currently active tasks are considered.

  • Date formatting is consistent in ISO format for ease of use in charts and display.

  • Label aggregation uses explicit join between Label and LabelsTask.

  • The handler assumes the session user is authorized to view the project (enforced outside this function or via the verify_session decorator).

  • The template /templates/testing_charts.jinja2 is expected to utilize the provided data for rendering charts and task lists.

Last updated