Skip to content

Projects 0.23.0: Fewer database reads on busy project pages

Projects 0.23.0 makes the module’s busiest pages cheaper to run. Twelve places that read the database once per project, task or person now read everything in one go, starting with the pages that refresh themselves on a timer.

The Overview and dashboard widgets

The Overview page and two dashboard widgets walked every project, and then every sub-project beneath it, one database read at a time. The Running projects widget does this every 15 seconds and the Projects calendar widget every 60 seconds, for each person who has them open. They now read all the tasks they need in one statement per level of sub-projects, however many projects there are.

Project pages

Opening a project page, or a change on its Modules panel, worked out which features were on with 22 separate reads. It now takes one. The Modules panel, the members page, the portal review queue and the Files page also stop looking things up item by item in a loop.

Bad data no longer loops

When building a project’s tree of sub-projects, the module now remembers the path it came down. If the data ever pointed a project back at one of its own parents, that branch is skipped instead of being followed round again. A sub-project at the depth limit is left out rather than shown as empty.

For apps that call the module

The batched reads are public, such as Projects.assignments_by_project/1 and Projects.project_tree_summaries/1, for apps that show many projects at once. The description of Projects.quick_add_assignment/3 now says what it does: it sets the title and nothing else.

Upgrading

No migration, no configuration and no change in what the pages show. Update the dependency.

Full release notes: Projects 0.23.0

0.23.0 · 5 September 2026

PR #41 — the per-item reads on the hot paths are batched. Twelve N+1s, the worst of them on surfaces that re-run on a timer.

Added

  • Projects.assignments_by_project/1 — the accepted assignments of a set of projects and every sub-project beneath them, as %{project_uuid => [Assignment.t()]}: one WHERE project_uuid IN (…) read per depth level rather than one per node. Filter, order and preloads are identical to list_assignments/1, which is what makes it a drop-in base for the tree walkers.
  • Projects.project_tree_summaries/1 and ScheduleLayout.trees/1 — the plural forms of project_tree_summary/1 and tree/1, built off that one read. The singular forms delegate to them, so both shapes stay in step.
  • Features.flags/1, Extensions.enabled_map/1, Grants.subject_reaches/1, Portal.review_details_for/1, People.names_by_uuid/2, Attachments.download_urls/1 — batched forms of the per-item lookups the Modules panel, the members page, the review queue and the files page were making in a loop.
  • Projects.max_subproject_depth/0 — the depth bound the forest read and both tree builders share, so the loader and the builders cannot disagree about where to stop.
  • Projects.list_all_dependencies/1 now also accepts a list of project uuids.
  • test/support/query_counter.ex — counts the statements a function runs, via repo telemetry, so the new suites assert what actually matters: that the count follows the depth, not the number of projects.

Changed

  • The dashboard widgets and the Overview no longer re-run the per-project N+1. RunningWidget (every 15 s), CalendarWidget (every 60 s) and OverviewLive walked project_tree_summary/1 — and ScheduleLayout.tree/1 — once per project and recursively per sub-project. On a page that refreshes on a tick, per connected viewer, that is the cost that matters.
  • Features.gates/1 resolves from one context read. It was asking the database per flag and per requires hop — 22 reads for the 16 gates, on every project-page mount and every modules-changed broadcast.
  • Both tree builders now carry the set of projects on the path down to them, so a cycle in bad data is skipped at the edge instead of recursing; and a node at the depth cap is not built at all rather than read as falsely empty.

Fixed

  • Projects.quick_add_assignment/3 documented itself as adding the task “with the project’s defaults”. It sets the title and nothing else — the assignment takes the schema’s own defaults plus the computed bottom position. opts is accepted and ignored; the doc now says so.
  • RunningTiers.prioritize/4 hand-rolled a Schwartzian transform that Enum.sort_by/2 already performs.

Projects 0.23.0. Install or update: {:phoenix_kit_projects, "~> 0.23"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.