Skip to content

Name every stream by one hyphenated id: stock-market, stock-split, us-national-weather #93

Description

@jeff1evesque

Problem

A stream goes by several names on this site, and each page converts between them itself:

Where S&P 500 Stock Splits US Weather Alerts
urls the site links StockMarket StockMarketStockSplit USNationalWeather
requests to the performance api stockmarket stockmarketstocksplit usnationalweather
the alarm page's own state stock-market stockmarketstocksplit us-national-weather
file names featured/stock-market.jsx trigger/content/stock-split.jsx trigger/content/us-national-weather.jsx
datalake Data, via DATASETS stock-market stock-split us-weather-alert

Two of those conversions are wrong today:

  • The Stock Splits trigger page is empty.
    • The /stream page links it as /stream/StockMarketStockSplit/trigger, but trigger.jsx renders the split content only for stocksplit. No other branch matches, so the page shows no content.
    • Its test passes because it routes to /stream/StockSplit/trigger, a url the site never links.
  • Two alarm pages name their stream by its id.
    • alarm.jsx renames StockMarket to stock-market and USNationalWeather to us-national-weather. It then labels the page with streamName(), which knows only the unhyphenated ids.
    • As a result, the S&P 500 page reads "Download raw stock-market ingest performance metrics", and the weather page says "us-national-weather" where it should say "US Weather Alerts".

Proposal

The performance api will accept stock-market, stock-split, bls, sec and us-national-weather, and will keep accepting today's ids while the site moves. Make those five the site's only stream ids:

  • One module owns the ids. Add jsx/import/general/stream-id.js, holding the five ids and a canonicalStream(). That function maps every form in use today to one of the five, or to null. The forms include StockMarket, stockmarket, StockMarketStockSplit, StockSplit, USNationalWeather and BLS.
  • Urls use the ids. For example /stream/stock-market/alarm, /stream/stock-split/trigger, /stream?item=us-national-weather&rate=Day and /data?item=stock-market. An old url still loads, and is replaced with its canonical form, so bookmarks and shared links keep working.
  • Requests send the ids, such as Stream=stock-market.
  • The archive column matches the listing through canonicalStream(). It then shows the same files whichever ids the listing uses.
  • Everything keyed by a stream uses its id. That covers STREAM_LABELS, STREAM_COVERAGE, DATASETS, the ingest schedules and gaps, the per-stream state keys and the css classes.
  • Pages stop converting ids themselves. Remove the renames in alarm.jsx, and the 'stocksplit' and 'usnationalweather' comparisons in trigger.jsx.
  • Docs:
    • In documentation/api/openapi/performance.json, update the Stream enum, the archive's stream enum, the id pattern (to ^[a-z-]+/...) and every example.
    • In documentation/api/performance.md, update the parameter table, and say that the old ids are still accepted for now.

Acceptance criteria

  • Every link the site builds uses one of the five ids.
  • Every old url still loads, and ends on its canonical url. That includes /stream/StockMarket/alarm, /stream/StockMarketStockSplit/trigger, /stream?item=USNationalWeather&rate=Day and /data?item=StockMarket.
  • /stream/stock-split/trigger renders the split content, and a test routes to the url the /stream page links.
  • Every alarm page names its stream by label, such as "S&P 500" or "US Weather Alerts", and never by id.
  • The archive column shows the same files before and after the api starts naming streams by the new ids.
  • The documented examples use the new ids.

Order

  1. The performance api accepts the hyphenated ids.
  2. This issue.
  3. The performance api names streams by the hyphenated ids in its answers.

Merge this only after step 1 is live. Until then, a request with a new id is answered with a 400.

Out of scope

  • The datalake's dataset names. us-weather-alert stays, and DATASETS maps the new ids onto it.
  • Where the archive files live. Their folders stay put, because the listing gives each file's url.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions