From c6b4b451ff52a8c8c5dc73f92a854e20ce118ff7 Mon Sep 17 00:00:00 2001 From: Pdzly Date: Tue, 16 Dec 2025 20:08:02 +0100 Subject: [PATCH 1/3] - Add `docker-compose.dev.yml` for development environment with Postgres setup - Remove unnecessary blank lines in `timespan.ts` - Refactor regex group access and simplify duration calculation logic --- docker-compose.dev.yml | 24 ++++++++++++++++++++++++ src/util/timespan.ts | 6 ++---- 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 docker-compose.dev.yml diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 00000000..725f9b56 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,24 @@ +version: '3.8' + +services: + postgres: + image: postgres:16 + container_name: postgres-dev + restart: unless-stopped + environment: + POSTGRES_USER: root + POSTGRES_PASSWORD: password + POSTGRES_DB: database + ports: + - "3306:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U postgres" ] + interval: 10s + timeout: 5s + retries: 5 + +volumes: + postgres_data: + driver: local \ No newline at end of file diff --git a/src/util/timespan.ts b/src/util/timespan.ts index bd9631c1..07ae64d8 100644 --- a/src/util/timespan.ts +++ b/src/util/timespan.ts @@ -24,12 +24,10 @@ function getDuration(duration: string): number { case "minute": case "m": return 1000 * 60; - case "seconds": case "second": case "s": return 1000; - default: return 0; } @@ -52,9 +50,9 @@ export function parseTimespan(span: string): number { let out = 0; for (const element of inputSplit) { - const number = parseInt(element.groups?.[1] ?? "0", 10); + const number = Number.parseInt(element[1], 10); if (Number.isNaN(number)) continue; - out += number * getDuration(element.groups?.[2] ?? ""); + out += number * getDuration(element[2]); } return out; } From 81e74265f08934582bb00787b22d13313c70bb66 Mon Sep 17 00:00:00 2001 From: Rooki <34943569+Pdzly@users.noreply.github.com> Date: Sun, 21 Dec 2025 13:33:43 +0100 Subject: [PATCH 2/3] Delete docker-compose.dev.yml --- docker-compose.dev.yml | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 docker-compose.dev.yml diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml deleted file mode 100644 index 725f9b56..00000000 --- a/docker-compose.dev.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: '3.8' - -services: - postgres: - image: postgres:16 - container_name: postgres-dev - restart: unless-stopped - environment: - POSTGRES_USER: root - POSTGRES_PASSWORD: password - POSTGRES_DB: database - ports: - - "3306:5432" - volumes: - - postgres_data:/var/lib/postgresql/data - healthcheck: - test: [ "CMD-SHELL", "pg_isready -U postgres" ] - interval: 10s - timeout: 5s - retries: 5 - -volumes: - postgres_data: - driver: local \ No newline at end of file From 2e04e0702fd3eac08c9ce27d078e548829dca9b5 Mon Sep 17 00:00:00 2001 From: Pdzly Date: Tue, 16 Dec 2025 20:08:02 +0100 Subject: [PATCH 3/3] - Remove unnecessary blank lines in time unit cases - Update regex group access from `.groups` to direct array indexing - Simplify duration calculation by using direct element access instead of optional chaining --- docker-compose.dev.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 docker-compose.dev.yml diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 00000000..725f9b56 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,24 @@ +version: '3.8' + +services: + postgres: + image: postgres:16 + container_name: postgres-dev + restart: unless-stopped + environment: + POSTGRES_USER: root + POSTGRES_PASSWORD: password + POSTGRES_DB: database + ports: + - "3306:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U postgres" ] + interval: 10s + timeout: 5s + retries: 5 + +volumes: + postgres_data: + driver: local \ No newline at end of file