feat: change range offer to use date range

add date range type
change availability filter
This commit is contained in:
Wieland Schöbl
2021-05-03 16:57:38 +02:00
committed by Jovan Krunić
parent 56b03aa0b9
commit 9c6972af78
9 changed files with 103 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 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.
@@ -33,17 +33,17 @@ export interface SCSearchAvailabilityFilter extends SCSearchAbstractFilter<SCAva
*/
export interface SCAvailabilityFilterArguments extends SCSearchAbstractFilterArguments {
/**
* Field which marks the start of the availability
* Field which marks availability range
*/
fromField: SCThingsField;
field: SCThingsField;
/**
* Time to check. Defaults to 'now'
* If set, the provided time will apply to the full hour, day, week, etc.
*/
time?: SCISO8601Date | 'now';
scope?: 's' | 'm' | 'H' | 'd' | 'w' | 'M' | 'y';
/**
* Field which marks the end of the availability
* Time to check. Defaults current time if not set
*/
toField: SCThingsField;
time?: SCISO8601Date;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 StApps
* Copyright (C) 2020-2021 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.
@@ -85,6 +85,15 @@ export interface SCRangeFilterArguments<T> extends SCSearchAbstractFilterArgumen
* Field where the filter will be applied
*/
field: SCThingsField;
/**
* Relation when searching on other range fields
*
* Intersects (Default): Both search and field range intersect
* Within: Search range is within the field range
* Contains: Search range contains the field range
*/
relation?: 'intersects' | 'within' | 'contains';
}
export interface Bounds<T> {

View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2021 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 {SCISO8601Date} from '../../general/time';
/**
* Date Range
*
* CAUTION: Changing the name requires changes in the core-tools premaps
*/
export type SCISO8601DateRange = SCRange<SCISO8601Date>;
/**
* Generic range type
*/
export type SCRange<T> = {
/**
* Greater than value
*/
gt?: never;
/**
* Greater or equal to value
*/
gte?: T;
/**
* Greater than value
*/
lt?: never;
/**
* Greater or equal to value
*/
lte?: T;
} | {
// tslint:disable:completed-docs
gt?: T;
gte?: never;
lt?: T;
lte?: never;
} | {
gt?: T;
gte?: never;
lt?: never;
lte?: T;
} | {
gt?: never;
gte?: T;
lt?: T;
lte?: never;
// tslint:enable:completed-docs
};

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 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.
@@ -13,10 +13,10 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SCMetaTranslations, SCTranslations} from '../../general/i18n';
import {SCISO8601Date} from '../../general/time';
import {SCOrganizationWithoutReferences} from '../organization';
import {SCPersonWithoutReferences} from '../person';
import {SCInPlace} from './place';
import {SCISO8601DateRange} from './range';
import {SCThing, SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
/**
@@ -100,14 +100,9 @@ export interface SCThingThatCanBeOfferedOffer<T extends SCPriceGroup>
availability: SCThingThatCanBeOfferedAvailability;
/**
* The time when the thing becomes unavailable as an SCISO8601Date formatted string.
* The time when the thing is available.
*/
availabilityEnds?: SCISO8601Date;
/**
* The time when the thing becomes available as an SCISO8601Date formatted string.
*/
availabilityStarts?: SCISO8601Date;
availabilityRange?: SCISO8601DateRange;
/**
* List of prices that are distinct for specific groups

View File

@@ -43,8 +43,10 @@
"offers": [
{
"availability": "in stock",
"availabilityStarts": "2017-01-30T00:00:00.000Z",
"availabilityEnds": "2017-01-30T23:59:59.999Z",
"availabilityRange": {
"gte": "2017-01-30T00:00:00.000Z",
"lte": "2017-01-30T23:59:59.999Z"
},
"prices": {
"default": 6.5,
"student": 5,

View File

@@ -19,8 +19,10 @@
"offers": [
{
"availability": "in stock",
"availabilityStarts": "2017-01-30T00:00:00.000Z",
"availabilityEnds": "2017-01-30T23:59:59.999Z",
"availabilityRange": {
"gte": "2017-01-30T00:00:00.000Z",
"lte": "2017-01-30T23:59:59.999Z"
},
"prices": {
"default": 4.85,
"student": 2.85,

View File

@@ -20,8 +20,10 @@
"uid": "3b9b3df6-3a7a-58cc-922f-c7335c002634"
},
"availability": "in stock",
"availabilityStarts": "2017-01-30T00:00:00.000Z",
"availabilityEnds": "2017-01-30T23:59:59.999Z",
"availabilityRange": {
"gte": "2017-01-30T00:00:00.000Z",
"lte": "2017-01-30T23:59:59.999Z"
},
"inPlace": {
"geo": {
"point": {

View File

@@ -11,9 +11,11 @@
],
"offers": [
{
"availabilityEnds": "2017-03-27T23:59:59.000Z",
"availabilityStarts": "2017-03-27T00:00:00.000Z",
"availability": "in stock",
"availabilityRange": {
"gte": "2017-03-27T00:00:00.000Z",
"lte": "2017-03-27T23:59:59.000Z"
},
"inPlace": {
"type": "room",
"name": "Cafeteria LEVEL",

View File

@@ -22,8 +22,8 @@
},
{
"arguments": {
"fromField": "availabilityStarts",
"toField": "availabilityEnds",
"scope": "d",
"field": "availabilityRange",
"time": "2018-01-15T04:13:00+00:00"
},
"type": "availability"