fix: remove usage of probability field (#5877)

- fixes #5735

---------

Co-authored-by: Marie Stoppa <marie.stoppa@essec.edu>
This commit is contained in:
Siddhant Rai 2024-07-16 13:54:35 +05:30 committed by GitHub
parent c0f6f52669
commit 364caf0fdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 14 additions and 64 deletions

View File

@ -333,7 +333,6 @@ export enum FieldMetadataType {
Numeric = 'NUMERIC',
Phone = 'PHONE',
Position = 'POSITION',
Probability = 'PROBABILITY',
Rating = 'RATING',
RawJson = 'RAW_JSON',
Relation = 'RELATION',

View File

@ -246,7 +246,6 @@ export enum FieldMetadataType {
Numeric = 'NUMERIC',
Phone = 'PHONE',
Position = 'POSITION',
Probability = 'PROBABILITY',
Rating = 'RATING',
RawJson = 'RAW_JSON',
Relation = 'RELATION',

View File

@ -39,11 +39,6 @@ export const formatFieldMetadataItemsAsFilterDefinitions = ({
return acc;
}
// Todo: remove once Rating fieldtype is implemented
if (field.name === 'probability') {
return acc;
}
return [...acc, formatFieldMetadataItemAsFilterDefinition({ field })];
}, [] as FilterDefinition[]);

View File

@ -82,7 +82,7 @@ export const usePersistField = () => {
isFieldBoolean(fieldDefinition) &&
isFieldBooleanValue(valueToPersist);
const fieldIsProbability =
const fieldIsRating =
isFieldRating(fieldDefinition) && isFieldRatingValue(valueToPersist);
const fieldIsNumber =
@ -119,7 +119,7 @@ export const usePersistField = () => {
fieldIsText ||
fieldIsBoolean ||
fieldIsEmail ||
fieldIsProbability ||
fieldIsRating ||
fieldIsNumber ||
fieldIsDateTime ||
fieldIsDate ||

View File

@ -51,19 +51,17 @@ type AssertFieldMetadataFunction = <
? FieldNumberMetadata
: E extends 'PHONE'
? FieldPhoneMetadata
: E extends 'PROBABILITY'
? FieldRatingMetadata
: E extends 'RELATION'
? FieldRelationMetadata
: E extends 'TEXT'
? FieldTextMetadata
: E extends 'UUID'
? FieldUuidMetadata
: E extends 'ADDRESS'
? FieldAddressMetadata
: E extends 'RAW_JSON'
? FieldRawJsonMetadata
: never,
: E extends 'RELATION'
? FieldRelationMetadata
: E extends 'TEXT'
? FieldTextMetadata
: E extends 'UUID'
? FieldUuidMetadata
: E extends 'ADDRESS'
? FieldAddressMetadata
: E extends 'RAW_JSON'
? FieldRawJsonMetadata
: never,
>(
fieldType: E,
fieldTypeGuard: (

View File

@ -102,11 +102,6 @@ export const SETTINGS_FIELD_TYPE_CONFIGS = {
Icon: IconPhone,
defaultValue: '+1234-567-890',
},
[FieldMetadataType.Probability]: {
label: 'Rating',
Icon: IconTwentyStar,
defaultValue: '3',
},
[FieldMetadataType.Rating]: {
label: 'Rating',
Icon: IconTwentyStar,

View File

@ -161,7 +161,7 @@ export const SettingsObjectNewFieldStep2 = () => {
// FieldMetadataType.FullName,
FieldMetadataType.Link,
FieldMetadataType.Numeric,
FieldMetadataType.Probability,
// FieldMetadataType.Probability,
// FieldMetadataType.Uuid,
// FieldMetadataType.Phone,
] as const

View File

@ -145,13 +145,6 @@ const fieldNumericMock = {
defaultValue: null,
};
const fieldProbabilityMock = {
name: 'fieldProbability',
type: FieldMetadataType.PROBABILITY,
isNullable: true,
defaultValue: null,
};
const fieldFullNameMock = {
name: 'fieldFullName',
type: FieldMetadataType.FULL_NAME,
@ -206,7 +199,6 @@ export const fields = [
fieldBooleanMock,
fieldNumberMock,
fieldNumericMock,
fieldProbabilityMock,
fieldLinkMock,
fieldLinksMock,
fieldCurrencyMock,

View File

@ -73,7 +73,6 @@ export class TypeMapperService {
),
],
[FieldMetadataType.NUMERIC, BigFloatScalarType],
[FieldMetadataType.PROBABILITY, GraphQLFloat],
[FieldMetadataType.POSITION, PositionScalarType],
[FieldMetadataType.RAW_JSON, RawJSONScalar],
]);
@ -109,7 +108,6 @@ export class TypeMapperService {
),
],
[FieldMetadataType.NUMERIC, BigFloatFilterType],
[FieldMetadataType.PROBABILITY, FloatFilterType],
[FieldMetadataType.POSITION, FloatFilterType],
[FieldMetadataType.RAW_JSON, RawJsonFilterType],
]);
@ -130,7 +128,6 @@ export class TypeMapperService {
[FieldMetadataType.BOOLEAN, OrderByDirectionType],
[FieldMetadataType.NUMBER, OrderByDirectionType],
[FieldMetadataType.NUMERIC, OrderByDirectionType],
[FieldMetadataType.PROBABILITY, OrderByDirectionType],
[FieldMetadataType.RATING, OrderByDirectionType],
[FieldMetadataType.SELECT, OrderByDirectionType],
[FieldMetadataType.MULTI_SELECT, OrderByDirectionType],

View File

@ -55,9 +55,6 @@ describe('computeSchemaComponents', () => {
fieldNumeric: {
type: 'number',
},
fieldProbability: {
type: 'number',
},
fieldLink: {
properties: {
label: { type: 'string' },

View File

@ -35,7 +35,6 @@ const getFieldProperties = (type: FieldMetadataType): Property => {
case FieldMetadataType.NUMBER:
return { type: 'integer' };
case FieldMetadataType.NUMERIC:
case FieldMetadataType.PROBABILITY:
case FieldMetadataType.RATING:
case FieldMetadataType.POSITION:
return { type: 'number' };

View File

@ -31,7 +31,6 @@ export enum FieldMetadataType {
BOOLEAN = 'BOOLEAN',
NUMBER = 'NUMBER',
NUMERIC = 'NUMERIC',
PROBABILITY = 'PROBABILITY',
LINK = 'LINK',
LINKS = 'LINKS',
CURRENCY = 'CURRENCY',

View File

@ -35,7 +35,6 @@ type FieldMetadataDefaultValueMapping = {
[FieldMetadataType.NUMBER]: FieldMetadataDefaultValueNumber;
[FieldMetadataType.POSITION]: FieldMetadataDefaultValueNumber;
[FieldMetadataType.NUMERIC]: FieldMetadataDefaultValueString;
[FieldMetadataType.PROBABILITY]: FieldMetadataDefaultValueNumber;
[FieldMetadataType.LINK]: FieldMetadataDefaultValueLink;
[FieldMetadataType.LINKS]: FieldMetadataDefaultValueLinks;
[FieldMetadataType.CURRENCY]: FieldMetadataDefaultValueCurrency;

View File

@ -78,18 +78,6 @@ describe('validateDefaultValueForType', () => {
).toBe(false);
});
it('should validate number default value for PROBABILITY type', () => {
expect(
validateDefaultValueForType(FieldMetadataType.PROBABILITY, 0.5).isValid,
).toBe(true);
});
it('should return false for invalid number default value for PROBABILITY type', () => {
expect(
validateDefaultValueForType(FieldMetadataType.PROBABILITY, '50%').isValid,
).toBe(false);
});
it('should validate boolean default value for BOOLEAN type', () => {
expect(
validateDefaultValueForType(FieldMetadataType.BOOLEAN, true).isValid,

View File

@ -41,7 +41,6 @@ export const defaultValueValidatorsMap = {
[FieldMetadataType.BOOLEAN]: [FieldMetadataDefaultValueBoolean],
[FieldMetadataType.NUMBER]: [FieldMetadataDefaultValueNumber],
[FieldMetadataType.NUMERIC]: [FieldMetadataDefaultValueString],
[FieldMetadataType.PROBABILITY]: [FieldMetadataDefaultValueNumber],
[FieldMetadataType.LINK]: [FieldMetadataDefaultValueLink],
[FieldMetadataType.CURRENCY]: [FieldMetadataDefaultValueCurrency],
[FieldMetadataType.FULL_NAME]: [FieldMetadataDefaultValueFullName],

View File

@ -25,7 +25,6 @@ export type BasicFieldMetadataType =
| FieldMetadataType.EMAIL
| FieldMetadataType.NUMERIC
| FieldMetadataType.NUMBER
| FieldMetadataType.PROBABILITY
| FieldMetadataType.BOOLEAN
| FieldMetadataType.POSITION
| FieldMetadataType.DATE_TIME

View File

@ -22,7 +22,6 @@ export const fieldMetadataTypeToColumnType = <Type extends FieldMetadataType>(
case FieldMetadataType.NUMERIC:
return 'numeric';
case FieldMetadataType.NUMBER:
case FieldMetadataType.PROBABILITY:
case FieldMetadataType.POSITION:
return 'float';
case FieldMetadataType.BOOLEAN:

View File

@ -72,10 +72,6 @@ export class WorkspaceMigrationFactory {
[FieldMetadataType.NUMBER, { factory: this.basicColumnActionFactory }],
[FieldMetadataType.POSITION, { factory: this.basicColumnActionFactory }],
[FieldMetadataType.RAW_JSON, { factory: this.basicColumnActionFactory }],
[
FieldMetadataType.PROBABILITY,
{ factory: this.basicColumnActionFactory },
],
[FieldMetadataType.BOOLEAN, { factory: this.basicColumnActionFactory }],
[FieldMetadataType.DATE_TIME, { factory: this.basicColumnActionFactory }],
[FieldMetadataType.DATE, { factory: this.basicColumnActionFactory }],