refactor: move location from the dish to its offers

This commit is contained in:
Michel Jonathan Schmitz
2019-02-22 10:02:11 +01:00
parent ac08d226e9
commit d2eeaeffd8
9 changed files with 102 additions and 51 deletions

18
package-lock.json generated
View File

@@ -284,9 +284,9 @@
"integrity": "sha512-MhCUjojzDhVLnZnxwPwa+rETFRDQ0ffjxYdrqOP6TBO2O0/Z64PV5tNeYApo4bc4y4frbWOrRwv/eEkXlI13Rw==" "integrity": "sha512-MhCUjojzDhVLnZnxwPwa+rETFRDQ0ffjxYdrqOP6TBO2O0/Z64PV5tNeYApo4bc4y4frbWOrRwv/eEkXlI13Rw=="
}, },
"@types/lodash": { "@types/lodash": {
"version": "4.14.121", "version": "4.14.120",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.121.tgz", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.120.tgz",
"integrity": "sha512-ORj7IBWj13iYufXt/VXrCNMbUuCTJfhzme5kx9U/UtcIPdJYuvPDUAlHlbNhz/8lKCLy9XGIZnGrqXOtQbPGoQ==", "integrity": "sha512-jQ21kQ120mo+IrDs1nFNVm/AsdFxIx2+vZ347DbogHJPd/JzKNMOqU6HCYin1W6v8l5R9XSO2/e9cxmn7HAnVw==",
"dev": true "dev": true
}, },
"@types/marked": { "@types/marked": {
@@ -314,9 +314,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "11.9.3", "version": "11.9.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-11.9.3.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-11.9.4.tgz",
"integrity": "sha512-DMiqG51GwES/c4ScBY0u5bDlH44+oY8AeYHjY1SGCWidD7h08o1dfHue/TGK7REmif2KiJzaUskO+Q0eaeZ2fQ==", "integrity": "sha512-Zl8dGvAcEmadgs1tmSPcvwzO1YRsz38bVJQvH1RvRqSR9/5n61Q1ktcDL0ht3FXWR+ZpVmXVwN1LuH4Ax23NsA==",
"dev": true "dev": true
}, },
"@types/nodemailer": { "@types/nodemailer": {
@@ -340,9 +340,9 @@
} }
}, },
"@types/shelljs": { "@types/shelljs": {
"version": "0.8.3", "version": "0.8.2",
"resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.3.tgz", "resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.2.tgz",
"integrity": "sha512-miY41hqc5SkRlsZDod3heDa4OS9xv8G77EMBQuSpqq86HBn66l7F+f8y9YKm+1PIuwC8QEZVwN8YxOOG7Y67fA==", "integrity": "sha512-vVp7BCQn0yUQgpiohrdxAhHdm/bTlXshB4HG3LEBq1PgvjKiyeYHohIPIv0QBt/jipb140iMS5Xy1iR6qKovKw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/glob": "*", "@types/glob": "*",

View File

@@ -46,7 +46,7 @@
"@openstapps/logger": "0.0.5", "@openstapps/logger": "0.0.5",
"@types/chai": "4.1.7", "@types/chai": "4.1.7",
"@types/humanize-string": "1.0.0", "@types/humanize-string": "1.0.0",
"@types/node": "11.9.3", "@types/node": "11.9.4",
"@types/rimraf": "2.0.2", "@types/rimraf": "2.0.2",
"async-pool-native": "0.1.0", "async-pool-native": "0.1.0",
"chai": "4.2.0", "chai": "4.2.0",

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 StApps * Copyright (C) 2018-2019 StApps
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -13,19 +13,9 @@
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThing} from '../Thing'; import {SCThing} from '../Thing';
import {SCBuildingWithoutReferences} from '../things/Building'; import {SCInPlace} from '../types/Places';
import {SCPointOfInterestWithoutReferences} from '../things/PointOfInterest';
import {SCRoomWithoutReferences} from '../things/Room';
/** /**
* A thing that is or happens in a place * A thing that is or happens in a place
*/ */
export interface SCThingInPlace extends SCThing { export interface SCThingInPlace extends SCThing, SCInPlace {}
/**
* Place the thing is or happens in
*/
inPlace?:
SCBuildingWithoutReferences
| SCPointOfInterestWithoutReferences
| SCRoomWithoutReferences;
}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 StApps * Copyright (C) 2018-2019 StApps
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -13,13 +13,11 @@
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThing, SCThingTranslatableProperties} from '../Thing'; import {SCThing, SCThingTranslatableProperties} from '../Thing';
import {SCBuildingWithoutReferences} from '../things/Building';
import {SCOrganizationWithoutReferences} from '../things/Organization'; import {SCOrganizationWithoutReferences} from '../things/Organization';
import {SCPersonWithoutReferences} from '../things/Person'; import {SCPersonWithoutReferences} from '../things/Person';
import {SCPointOfInterestWithoutReferences} from '../things/PointOfInterest';
import {SCRoomWithoutReferences} from '../things/Room';
import {SCTranslations} from '../types/i18n'; import {SCTranslations} from '../types/i18n';
import {SCISO8601Date} from '../types/Time'; import {SCISO8601Date} from '../types/Time';
import {SCInPlace} from './../types/Places';
/** /**
* A map from group name to price * A map from group name to price
@@ -51,7 +49,8 @@ export interface SCAcademicPriceGroup extends SCPriceGroup {
/** /**
* A thing without references that has a price tag * A thing without references that has a price tag
*/ */
export interface SCThingThatCanBeOffered<T extends SCPriceGroup> extends SCThing { export interface SCThingThatCanBeOffered<T extends SCPriceGroup>
extends SCThing {
/** /**
* List of offers for that thing * List of offers for that thing
*/ */
@@ -66,7 +65,8 @@ export interface SCThingThatCanBeOffered<T extends SCPriceGroup> extends SCThing
/** /**
* Offer of a thing * Offer of a thing
*/ */
export interface SCThingThatCanBeOfferedOffer<T extends SCPriceGroup> { export interface SCThingThatCanBeOfferedOffer<T extends SCPriceGroup>
extends SCInPlace {
/** /**
* Availability of an offer * Availability of an offer
*/ */
@@ -101,7 +101,8 @@ export interface SCThingThatCanBeOfferedOffer<T extends SCPriceGroup> {
/** /**
* Translatable properties of a thing that can be offered * Translatable properties of a thing that can be offered
*/ */
export interface SCThingThatCanBeOfferedTranslatableProperties extends SCThingTranslatableProperties { export interface SCThingThatCanBeOfferedTranslatableProperties
extends SCThingTranslatableProperties {
/** /**
* Availability of an offer * Availability of an offer
*/ */
@@ -109,20 +110,17 @@ export interface SCThingThatCanBeOfferedTranslatableProperties extends SCThingTr
} }
/** /**
* Possible things a provider can be * Entity responsible for the offer
*/ */
export type SCThingThatCanBeOfferedProvider = export type SCThingThatCanBeOfferedProvider =
SCBuildingWithoutReferences
| SCOrganizationWithoutReferences | SCOrganizationWithoutReferences
| SCPersonWithoutReferences | SCPersonWithoutReferences;
| SCPointOfInterestWithoutReferences
| SCRoomWithoutReferences;
/** /**
* Availability of an Offer * Availability of an Offer
*/ */
export type SCThingThatCanBeOfferedAvailability = export type SCThingThatCanBeOfferedAvailability =
'in stock' | 'in stock'
| 'out of stock' | 'out of stock'
| 'online only' | 'online only'
| 'limited availability'; | 'limited availability';

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 StApps * Copyright (C) 2018-2019 StApps
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
@@ -12,7 +12,6 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {SCThingInPlace} from '../base/ThingInPlace';
import { import {
SCAcademicPriceGroup, SCAcademicPriceGroup,
SCThingThatCanBeOffered, SCThingThatCanBeOffered,
@@ -30,8 +29,10 @@ import {SCTranslations} from '../types/i18n';
* A dish without references * A dish without references
*/ */
export interface SCDishWithoutReferences export interface SCDishWithoutReferences
extends SCThingWithCategoriesWithoutReferences<SCDishCategories, extends SCThingWithCategoriesWithoutReferences<
SCThingWithCategoriesSpecificValues>, SCDishCategories,
SCThingWithCategoriesSpecificValues
>,
SCThingThatCanBeOffered<SCAcademicPriceGroup> { SCThingThatCanBeOffered<SCAcademicPriceGroup> {
/** /**
* Additives of the dish * Additives of the dish
@@ -69,7 +70,7 @@ export interface SCDishWithoutReferences
* *
* @validatable * @validatable
*/ */
export interface SCDish extends SCDishWithoutReferences, SCThingInPlace { export interface SCDish extends SCDishWithoutReferences {
/** /**
* Dishes ("Beilagen") that are served with the dish (if only certain supplement dishes can be taken with a dish) * Dishes ("Beilagen") that are served with the dish (if only certain supplement dishes can be taken with a dish)
*/ */
@@ -87,8 +88,8 @@ export interface SCDish extends SCDishWithoutReferences, SCThingInPlace {
} }
export interface SCDishTranslatableProperties export interface SCDishTranslatableProperties
extends SCThingWithCategoriesTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties { extends SCThingWithCategoriesTranslatableProperties,
} SCThingThatCanBeOfferedTranslatableProperties {}
/** /**
* Dish meta data * Dish meta data
@@ -121,7 +122,7 @@ export interface SCDishCharacteristic {
* A list of categories for dishes * A list of categories for dishes
*/ */
export type SCDishCategories = export type SCDishCategories =
'appetizer' | 'appetizer'
| 'salad' | 'salad'
| 'main dish' | 'main dish'
| 'dessert' | 'dessert'

32
src/core/types/Places.ts Normal file
View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCBuildingWithoutReferences} from '../things/Building';
import {SCPointOfInterestWithoutReferences} from '../things/PointOfInterest';
import {SCRoomWithoutReferences} from '../things/Room';
/**
* Something that is or happens in a place
*
* !Important!
* This is not a SCThing.
*/
export interface SCInPlace {
/**
* Place the thing is or happens in
*/
inPlace?:
SCBuildingWithoutReferences
| SCPointOfInterestWithoutReferences
| SCRoomWithoutReferences;
}

View File

@@ -27,6 +27,16 @@
"employee": 2.85 "employee": 2.85
}, },
"provider": { "provider": {
"name": "Studentenwerk",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
},
"type": "organization",
"uid": "3b9b3df6-3a7a-58cc-922f-c7335c002634"
},
"inPlace": {
"geo": { "geo": {
"point": { "point": {
"type": "Point", "type": "Point",

View File

@@ -14,10 +14,20 @@
"student": 2.45, "student": 2.45,
"employee": 2.45 "employee": 2.45
}, },
"provider": {
"name": "Studentenwerk",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
},
"type": "organization",
"uid": "3b9b3df6-3a7a-58cc-922f-c7335c002634"
},
"availability": "in stock", "availability": "in stock",
"availabilityStarts": "2017-01-30T00:00:00.000Z", "availabilityStarts": "2017-01-30T00:00:00.000Z",
"availabilityEnds": "2017-01-30T23:59:59.999Z", "availabilityEnds": "2017-01-30T23:59:59.999Z",
"provider": { "inPlace": {
"geo": { "geo": {
"point": { "point": {
"type": "Point", "type": "Point",

View File

@@ -14,12 +14,7 @@
"availabilityEnds": "2017-03-27T23:59:59.000Z", "availabilityEnds": "2017-03-27T23:59:59.000Z",
"availabilityStarts": "2017-03-27T00:00:00.000Z", "availabilityStarts": "2017-03-27T00:00:00.000Z",
"availability": "in stock", "availability": "in stock",
"prices": { "inPlace": {
"student": 4.9,
"employee": 6.5
},
"price": 6.5,
"provider": {
"type": "room", "type": "room",
"name": "Cafeteria LEVEL", "name": "Cafeteria LEVEL",
"categories": [ "categories": [
@@ -44,6 +39,21 @@
"name": "Dummy", "name": "Dummy",
"type": "remote" "type": "remote"
} }
},
"prices": {
"student": 4.9,
"employee": 6.5
},
"price": 6.5,
"provider": {
"name": "Studentenwerk",
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
},
"type": "organization",
"uid": "3b9b3df6-3a7a-58cc-922f-c7335c002634"
} }
} }
], ],