Skip to content

Commit

Permalink
chore: maintenance (#11)
Browse files Browse the repository at this point in the history
* chore: updated dependencies

* chore: added launch.json to debug tests

* fixed regex to handle latest state of wahlrecht.de

* ci: add workflow

* fix: set default timezone to europe/berlin

* chore: removed obsolete reduce call

* fix: possible NPE

* fix: template to handle missing results
Cephra authored Jul 26, 2024
1 parent 4709620 commit a66f61f
Showing 10 changed files with 5,595 additions and 3,401 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Continuous Integration

on:
push:

jobs:
run_tests:
name: Run tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Install dependencies
run: npm install
-
name: Run tests
run: npm run test
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/node_modules/jest-cli/bin/jest",
"args": [
"${fileBasename}",
"--verbose",
"-i",
"--no-cache",
"--watchAll",
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
6 changes: 3 additions & 3 deletions js/scraper.js
Original file line number Diff line number Diff line change
@@ -40,10 +40,10 @@ module.exports = {
)
.text()
.replace(',', '.')
.match(/\d+(?:.\d+)?/g)
.match(/(?:\d+(?:\.\d+)?|)/g)
.map((match) => parseFloat(match))
.reduce((acc, el) => acc+el, 0);

.pop();
return acc;
}, {})
};
15 changes: 13 additions & 2 deletions js/templates.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
const Handlebars = require('handlebars');
const dayjs = require("dayjs");

var utc = require("dayjs/plugin/utc");
const timezone = require("dayjs/plugin/timezone");

dayjs.extend(utc);
dayjs.extend(timezone);

dayjs.tz.setDefault('Europe/Berlin');

Handlebars.registerHelper('date', (timestamp) => {
return dayjs.unix(timestamp).format('DD.MM.YYYY');
return dayjs.unix(timestamp).tz().format('DD.MM.YYYY');
});

Handlebars.registerHelper('localize', (text, locale) => {
return text.toLocaleString(locale);
return (text ?? '').toLocaleString(locale);
});

const fs = require('fs');

const templatePattern = /(.+?)(?:\.(partial))?\.hbs/;
Loading

0 comments on commit a66f61f

Please sign in to comment.