Skip to content

Add a directory of the open data portals CanQuery mirrors - #146

Merged
RyuPrad merged 4 commits into
mainfrom
feat/portals-directory
Nov 16, 2026
Merged

RyuPrad merged 4 commits into
mainfrom
feat/portals-directory

Conversation

@RyuPrad

@RyuPrad RyuPrad commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

What & why

CanQuery mirrors 83 Canadian open data portals, but no page says so. /about names the sources in a paragraph, and the only list of portals is a filter on the catalogue. This adds /portals: one row per portal, with figures that exist nowhere else in one place.

For each portal the page gives:

  • its place and province, linked to that place's page;
  • its platform (CKAN, ArcGIS Hub, Socrata, Opendatasoft);
  • the datasets CanQuery holds from it, how many have a table to query here and how many have a map, each linked to those datasets in the catalogue;
  • its general licence, and the last day its catalogue was read.

Below the table the portals are grouped by level of government, by platform and by province or territory, and a short section says what each number means.

It is reference content of CanQuery's own: something a reader choosing a portal can use, and one page another site can link to when it wants to point at "the open data portals of Canada".

How it is built

  • One read. listPortalDirectory counts each portal's records from dataset_sources with the catalogue's own "has a table" and "has a map" rules, so the counts are the ones /datasets?source=… shows with the same filters. A dataset two portals list counts for both and once in the total, which is the number of different datasets the enabled sources hold between them. services/portalPages.js caches the result for ten minutes.
  • A portal's place comes from the source registry: the place its entry names, or names first. Where its records are placed does not decide it, so a region's portal that mostly holds its cities' records is still the region's.
  • The server's HTML carries the whole directory (the table, the three group tables, a CollectionPage whose list names each portal as a DataCatalog) and embeds the data, so the application draws the page without a request. An in-app visit reads /web-api/v1/portals, a website-only route outside /api/v1, its metering and the OpenAPI document.
  • The application filters by name or place, level, platform and province, and sorts by column; the address keeps the choice. Below 1024 pixels each portal is a card instead of a table row, so no figure is off screen.
  • Days. "Last read" is a day in Eastern time on the server and in the application: in UTC the page would show tomorrow's date every evening in Canada.
  • Discovery. The page is in /sitemap-pages.xml (dated by the day of the latest successful read), the navigation menu, the footer, the section links of every server-rendered page and the About page's "where the data comes from" section.

Also here: French portal names built from a city's name contract their article ("Données ouvertes du District de Squamish", not "de le District"). The stored name changes at that source's next sync.

Checklist

  • server: npm run lint && npm test pass
  • client: lint, scoped type/format checks, tests and production build pass
  • Required disposable database integration passes on the exact commit
  • Release artifact commit and manifest match the reviewed/tested build
  • Added/updated tests for the changed behavior
  • User-facing strings added to client/src/i18n.jsx (EN + FR), if any
  • No secrets, credentials, or production-specific details added

Notes

  • No migration and no new grant. The read names catalog_sources, dataset_sources, resources, ingested_resources, resource_maps, places and sync_runs; runtimeRoles.test.cjs runs it as the API role.
  • With no portal read yet the page answers 200 with noindex, carries no ad and stays out of the sitemap; a read that fails answers 503 on the page (500 on the JSON route, as the other website routes do), never an empty directory, and the sitemap keeps the page without a date.
  • Names and licences are printed as recorded and escaped; the official site and the licence are links only when they are plain http(s) addresses.
  • The server and the application say the same words: a test compares the server's headings, labels and method text with client/src/i18n.jsx.
  • Tests: portalPages.test.js (shape, cache, JSON route, HTML, structured data, escaping, sitemap, navigation), catalogDiscoveryIntegration.test.js (the read on PostgreSQL: counts, shared datasets, places, the catalogue total), catalogSources.test.js (French names), and on the client portals.test.js, portalData.test.js and PortalsPage.test.jsx (table, filters, sort, the address, cards on a narrow screen, one-portal wording, both languages).
  • Checked in Chromium and WebKit on a production build of the last commit, in English and French, at 390, 768, 1024 and 1280 pixels: no request for the directory on a direct visit, no sideways page scroll, layout shift under 0.1, filters and sort kept across a reload.
  • After review (second and third commits). An independent review of the first commit found no blocker and fifteen smaller points; these are fixed:
    • the description promised provincial portals (none is mirrored today, only a territory's): it now names no level of government, and the opening sentence gives the split by level only when it adds up;
    • "Last read" was the UTC day; the sitemap dated the page by each half-hourly read, dropped it for an hour after one failed read, and the index dated /sitemap-pages.xml older than its newest entry (the LMIA and OAS hubs had the same gap, closed here too);
    • in the application any 503 said "no portal is mirrored here yet" with no retry, and an unknown filter value in the address emptied the table under controls that looked unfiltered;
    • the three groups were h3 beside 83 card headings (now h2), the province group ignored French order, one dataset read "1 datasets";
    • the total counted a dataset only a switched-off source lists, a source named twice had no defined place, and the cache test passed with any duration;
    • the empty page was an ad page.
  • Operations notes are in deploy/indexing-discovery.md ("Portal directory").

/portals lists every enabled catalogue source as a portal: its place and
province, its platform, the datasets held from it, how many of them have a
table or a map here, its general licence and the last day it was read, with
the portals grouped by level of government, platform and province.

- One read (listPortalDirectory) counts each portal's records with the
  catalogue's own "has a table" and "has a map" rules; a portal's place
  comes from the source registry. Cached for ten minutes.
- The server's HTML carries the whole directory (table, group tables, a
  DataCatalog item list) and embeds the data, so the application draws the
  page with no request; an in-app visit reads /web-api/v1/portals.
- The application filters by name, place, level, platform and province and
  sorts by column, with the choice kept in the address. Below 1024 pixels
  each portal is a card, so no figure is off screen.
- The page is in /sitemap-pages.xml, the navigation menu, the footer and
  the section links of every server-rendered page.
- French portal names built from a city's name contract their article
  ("du District de Squamish", not "de le District").
After an independent review of the first commit.

- The description names no level of government (no province's own portal
  is mirrored today), and the lead gives the split by level only when it
  adds up: a portal whose place is unknown has no level.
- "Last read" is a day in Eastern time on the server and in the
  application, not the UTC day, which showed tomorrow's date every evening.
- The sitemap dates /portals by that day rather than by each half-hourly
  read, keeps the page listed when one read fails, and the index dates
  /sitemap-pages.xml by the newest entry the file holds (the LMIA and OAS
  hubs included).
- The total is the number of different datasets the enabled sources hold;
  a source named twice keeps the place it was given first.
- Structured data is a CollectionPage whose list names each DataCatalog,
  as the place and organization hubs are.
- The application: only the server's own "nothing mirrored yet" answer
  shows that message (any other 503 can be retried); a filter value the
  lists do not offer is ignored; the three groups are h2 sections; the
  province group follows the reader's alphabet; one dataset is "1 dataset".
- The page carries no ad while it has no portal to list: it is a 200
  that only says so.
- The About page's "where the data comes from" section links the list
  of those portals, in the server's HTML and in the application.
- A test holds the directory's cache to its ten minutes (and one minute
  for "nothing mirrored"): the earlier test passed with any duration.
@RyuPrad
RyuPrad merged commit b85bc9a into main Nov 16, 2026
12 checks passed
@RyuPrad
RyuPrad deleted the feat/portals-directory branch November 18, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant