From c776062d94ba352bd836439206602e33e404863c Mon Sep 17 00:00:00 2001 From: rcmenno <129762469+rcmenno@users.noreply.github.com> Date: Mon, 14 Oct 2024 13:24:39 +0200 Subject: [PATCH] Remove unused code bump to 0.4.0 --- PWA/package-lock.json | 6 +++--- PWA/package.json | 2 +- PWA/public/Services/Database.js | 24 ------------------------ PWA/public/Services/Database.test.js | 23 ----------------------- PWA/public/index.html | 2 +- PWA/src/Services/Database.test.ts | 26 +------------------------- PWA/src/Services/Database.ts | 26 -------------------------- 7 files changed, 6 insertions(+), 103 deletions(-) diff --git a/PWA/package-lock.json b/PWA/package-lock.json index df20b86..13343f5 100644 --- a/PWA/package-lock.json +++ b/PWA/package-lock.json @@ -25,7 +25,7 @@ "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", "dev": true, "dependencies": { - "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/gen-mapping": "^0.4.0", "@jridgewell/trace-mapping": "^0.3.9" }, "engines": { @@ -2557,8 +2557,8 @@ } }, "node_modules/@sinonjs/fake-timers": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.4.0.tgz", "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", "dev": true, "dependencies": { diff --git a/PWA/package.json b/PWA/package.json index d0e48a8..8a36ff5 100644 --- a/PWA/package.json +++ b/PWA/package.json @@ -1,6 +1,6 @@ { "name": "ReliefBox", - "version": "0.3.0", + "version": "0.4.0", "description": "A tool for managing the distribution of relief items during humanitarian emergencies.", "main": "index.js", "scripts": { diff --git a/PWA/public/Services/Database.js b/PWA/public/Services/Database.js index 485729f..4ab1636 100644 --- a/PWA/public/Services/Database.js +++ b/PWA/public/Services/Database.js @@ -5,13 +5,11 @@ export var ObjectStoreName; ObjectStoreName["distribution"] = "Distributions"; ObjectStoreName["beneficiary"] = "Beneficiaries"; ObjectStoreName["distributionBeneficiaries"] = "DistributionBeneficiary"; - ObjectStoreName["activeDistribution"] = "activeDistribution"; })(ObjectStoreName || (ObjectStoreName = {})); const allObjectStoreNames = [ ObjectStoreName.beneficiary, ObjectStoreName.distribution, ObjectStoreName.distributionBeneficiaries, - ObjectStoreName.activeDistribution, ]; function columnsForObjectStore(objectStore) { switch (objectStore) { @@ -35,13 +33,6 @@ function columnsForObjectStore(objectStore) { { name: "hasBeenMarkedAsReceived", isUnique: false }, { name: "dateReceived", isUnique: false } ]; - case ObjectStoreName.activeDistribution: - return [ - { name: "distrib_name", isUnique: false }, - { name: "distrib_place", isUnique: false }, - { name: "distrib_date", isUnique: false }, - { name: "distrib_items", isUnique: false }, - ]; } } export class Database { @@ -122,21 +113,6 @@ export class Database { async addBeneficiary(beneficiary) { return this.addElement(ObjectStoreName.beneficiary, beneficiary); } - async setActiveDistribution(activeDistribution) { - return this.addElement(ObjectStoreName.activeDistribution, activeDistribution); - } - async getActiveDistributions() { - return this.getElement(ObjectStoreName.activeDistribution); - } - async getActiveDistribution() { - const distributions = await this.getActiveDistributions(); - if (distributions.length > 0) { - return distributions[distributions.length - 1]; - } - else { - throw Error("No active distribution found"); - } - } async addBeneficiaryToDistribution(beneficiary, distribution) { const existing = await this.readDistributionBeneficiaries(); existing.forEach((curent) => { diff --git a/PWA/public/Services/Database.test.js b/PWA/public/Services/Database.test.js index 0230869..15a5f43 100644 --- a/PWA/public/Services/Database.test.js +++ b/PWA/public/Services/Database.test.js @@ -61,27 +61,4 @@ describe('Database', () => { expect(receivedBeneficiaries[0].hasBeenMarkedAsReceived).toEqual(true); expect(receivedBeneficiaries[1].hasBeenMarkedAsReceived).toEqual(true); }); - test("When setting an active distribution, they can be retrieved", async () => { - const distribution = new Distribution("12", "123", "Arnhem", "Name"); - try { - await sut.setActiveDistribution(distribution); - const result = await sut.getActiveDistributions(); - expect(result[0].distrib_name).toBe(distribution.distrib_name); - expect(result.length).toBe(1); - } - catch (error) { - expect(error.message).toBe("Empty"); - } - }); - test("When setting an active distribution, it can be retrieved", async () => { - const distribution = new Distribution("12", "123", "Arnhem", "Name"); - try { - await sut.setActiveDistribution(distribution); - const result = await sut.getActiveDistribution(); - expect(result.distrib_name).toBe(distribution.distrib_name); - } - catch (error) { - expect(error.message).toBe("Empty"); - } - }); }); diff --git a/PWA/public/index.html b/PWA/public/index.html index a1db876..3e19653 100644 --- a/PWA/public/index.html +++ b/PWA/public/index.html @@ -39,7 +39,7 @@ -
+ diff --git a/PWA/src/Services/Database.test.ts b/PWA/src/Services/Database.test.ts index f2ef998..db57615 100644 --- a/PWA/src/Services/Database.test.ts +++ b/PWA/src/Services/Database.test.ts @@ -1,10 +1,9 @@ -import {describe, test, expect, it} from '@jest/globals' +import {describe, test, expect } from '@jest/globals' import { Database } from "./Database"; import { Distribution } from '../Models/Distribution'; import { indexedDB } from "fake-indexeddb" import { Beneficiary } from '../Models/Beneficiary'; import { DistributionBeneficiary } from '../Models/DistributionBeneficiary'; -import { beforeEach } from 'node:test'; describe('Database', () => { const sut = new Database(indexedDB) @@ -99,27 +98,4 @@ describe('Database', () => { receivedBeneficiaries[1].hasBeenMarkedAsReceived ).toEqual(true) }) - - test("When setting an active distribution, they can be retrieved", async () => { - const distribution = new Distribution("12", "123", "Arnhem", "Name") - try { - await sut.setActiveDistribution(distribution) - const result = await sut.getActiveDistributions() - expect(result[0].distrib_name).toBe(distribution.distrib_name) - expect(result.length).toBe(1) - } catch(error: any) { - expect(error.message).toBe("Empty") - } - }) - - test("When setting an active distribution, it can be retrieved", async () => { - const distribution = new Distribution("12", "123", "Arnhem", "Name") - try { - await sut.setActiveDistribution(distribution) - const result = await sut.getActiveDistribution() - expect(result.distrib_name).toBe(distribution.distrib_name) - } catch(error: any) { - expect(error.message).toBe("Empty") - } - }) }); \ No newline at end of file diff --git a/PWA/src/Services/Database.ts b/PWA/src/Services/Database.ts index ced3077..757df91 100644 --- a/PWA/src/Services/Database.ts +++ b/PWA/src/Services/Database.ts @@ -10,13 +10,11 @@ export enum ObjectStoreName { distribution = "Distributions", beneficiary = "Beneficiaries", distributionBeneficiaries = "DistributionBeneficiary", - activeDistribution = "activeDistribution", } const allObjectStoreNames = [ ObjectStoreName.beneficiary, ObjectStoreName.distribution, ObjectStoreName.distributionBeneficiaries, - ObjectStoreName.activeDistribution, ]; type DatabaseColumn = { @@ -46,13 +44,6 @@ function columnsForObjectStore(objectStore: ObjectStoreName): DatabaseColumn[] { { name: "hasBeenMarkedAsReceived", isUnique: false }, { name: "dateReceived", isUnique: false } ]; - case ObjectStoreName.activeDistribution: - return [ - { name: "distrib_name", isUnique: false }, - { name: "distrib_place", isUnique: false }, - { name: "distrib_date", isUnique: false }, - { name: "distrib_items", isUnique: false }, - ]; } } @@ -160,23 +151,6 @@ export class Database { return this.addElement(ObjectStoreName.beneficiary, beneficiary); } - async setActiveDistribution(activeDistribution: Distribution): Promise