1.0.0 • Published 1 year ago

factbase v1.0.0

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
1 year ago

Usage

We aim for Factbase to be self-explanatory. Go to https://factbase.azurewebsites.net/

Manual deployment

Using VS Code, navigate to the Azure panel, at the top toolbar click button with tooltip Deploy to Function App.... Following the prompts, deploy it to:

Pay-As-You-Go Dev/Test -> displayr-functions

Wait. Verify. Commit your changes and continue.

It uses tasks.json to work out what it is doing.

Or: npm run deploy

URIscape

  • /static/pages/tiles.html, etc Pages.
  • /static/factbase.css, etc Other static content
  • /... AJAX API request served by Azure Functions.

Pre-Aggregated Data

Pre-aggregated data is sent to Factbase in multiple uploads. Each upload contains data for a particular combination of fixed dimensions. e.g. If aggregating over period (Day, Week) and Product (Q, Displayr) then you would post the following uploads:

  • An upload with fixed dimensions for Day and Q, with data points varied by date.
  • An upload with fixed dimensions for Week and Q, with data points varied by date.
  • An upload with fixed dimensions for Day and Displayr, with data points varied by date.
  • An upload with fixed dimensions for Day and Displayr, with data points varied by date.

Development

Environment Setup

  • Downloaded and installed v4.x Azure Functions Core Tools
  • Downloaded and install Azure CLI (az)
  • Update local.settings.json: func azure functionapp fetch-app-settings. This includes setting environment variables
  • Delete WEBSITE_RUN_FROM_PACKAGE to ensure changed JavaScript files are reloaded, which lets you run tsc --watch
  • Add "languageWorkers:node:arguments": "--inspect=5858" to ensure node listens for the debugger.
  • Install the following VS Code extensions:
    1. Azure Functions (installed by one of the previous?)
    2. PostgreSQL (Chris Kolkman)

Debugging the Functions

  1. Start npm run watch in one Terminal window.
  2. Run npm run start in another, which will listen for a debugger due to the languageWorkers:node:arguments setting you added to local.settings.json.
  3. If you need to de Run Launch functions and debug
  • Click Debug Anyway
  • Send requests with something like HTTPie.

Tests

WARNING: Some of these tests use the main database.

Notes on building

See package.conf for the real lowdown, but:

  • Node code is compiled by tsc into dist/.
  • Code to run in the browser is compiled by esbuild into dist/bundle
  • While developing, run npm watch in one window. It starts both tsc and esbuild in watch mode.
  • We are taking code directly out of ngviz-api-demonstrator. I had to install xml-name-validator manually. Hopefully I won't need this when ngviz-api-demonstrator is published with my changes.

Debugging the tests

  • Select the tab for the source file to debug in VS code.
  • Run Jest: current file (debug)

Running specific test files

  • npx jest tests/query.test.ts

Generating Protobuf files

npx pbjs rexp.proto RServerResponse.proto --wrap=commonjs --target=static-module --out=protobuf.js npx pbts protobuf.js --out=protobuf.d.ts

Policies of this codebase

  • No logging of tracing information to the browser console - keep it clean to make spotting problems easy.
  • Use undefined in preference to null
  • I cannot get deployment to work when Azure Functions are not stored in the root, because func doesn't package up necessary libraries in parent directories. For this reason all function folders are prefixed with f_ to make them obvious, and keep them together.