Skip to content

Commit

Permalink
Remove unused code bump to 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmenno committed Oct 14, 2024
1 parent 411c932 commit c776062
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 103 deletions.
6 changes: 3 additions & 3 deletions PWA/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion PWA/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
24 changes: 0 additions & 24 deletions PWA/public/Services/Database.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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) => {
Expand Down
23 changes: 0 additions & 23 deletions PWA/public/Services/Database.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
});
});
2 changes: 1 addition & 1 deletion PWA/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<!-- <a class="navbar-item">-->
<img src="images/ReliefBox-horizontal-nobackground.png" width="220" height="30">
<!-- </a>-->
<div class="navbar-item">Alpha 0.3.0</div>
<div class="navbar-item">Alpha 0.4.0</div>
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
Expand Down
26 changes: 1 addition & 25 deletions PWA/src/Services/Database.test.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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")
}
})
});
26 changes: 0 additions & 26 deletions PWA/src/Services/Database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 },
];
}
}

Expand Down Expand Up @@ -160,23 +151,6 @@ export class Database {
return this.addElement(ObjectStoreName.beneficiary, beneficiary);
}

async setActiveDistribution(activeDistribution: Distribution): Promise<void> {
return this.addElement(ObjectStoreName.activeDistribution, activeDistribution);
}

async getActiveDistributions(): Promise<Distribution[]> {
return this.getElement(ObjectStoreName.activeDistribution)
}

async getActiveDistribution(): Promise<Distribution> {
const distributions = await this.getActiveDistributions()
if(distributions.length > 0) {
return distributions[distributions.length - 1]
} else {
throw Error("No active distribution found")
}
}

async addBeneficiaryToDistribution(
beneficiary: Beneficiary,
distribution: Distribution
Expand Down

0 comments on commit c776062

Please sign in to comment.