From 1a54d91451656bc090bbc54bae26a87750bc85df Mon Sep 17 00:00:00 2001 From: Nathan Musoke Date: Thu, 6 Apr 2023 18:20:02 -0400 Subject: [PATCH] feat: Deep water solo discipline --- src/GradeUtils.ts | 7 ++++++- src/__tests__/gradeUtils.ts | 17 +++++++++++++++++ src/db/AreaSchema.ts | 1 + src/db/AreaTypes.ts | 1 + src/db/ClimbTypes.ts | 2 ++ src/db/export/Typesense/Utils.ts | 2 ++ src/graphql/schema/Area.gql | 1 + src/graphql/schema/Climb.gql | 2 ++ src/graphql/schema/ClimbEdit.gql | 2 ++ src/model/__tests__/MutableClimbDataSource.ts | 6 ++++++ 10 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/GradeUtils.ts b/src/GradeUtils.ts index 60628af0..8e48dad2 100644 --- a/src/GradeUtils.ts +++ b/src/GradeUtils.ts @@ -42,6 +42,7 @@ export const gradeContextToGradeScales: Partial ({ trad: false, sport: false, bouldering: false, + deepwatersolo: false, alpine: false, snow: false, ice: false, diff --git a/src/__tests__/gradeUtils.ts b/src/__tests__/gradeUtils.ts index f2a6ed0d..6613ebec 100644 --- a/src/__tests__/gradeUtils.ts +++ b/src/__tests__/gradeUtils.ts @@ -13,6 +13,7 @@ describe('Test grade utilities', () => { trad: true, sport: false, bouldering: false, + deepwatersolo: false, alpine: false, snow: false, ice: false, @@ -28,6 +29,7 @@ describe('Test grade utilities', () => { trad: false, sport: false, bouldering: true, + deepwatersolo: false, alpine: false, snow: false, ice: false, @@ -57,6 +59,11 @@ describe('Test grade utilities', () => { wi: 'WI2' }) + actual = createGradeObject('5.10a', sanitizeDisciplines({ deepwatersolo: true }), context) + expect(actual).toEqual({ + yds: '5.10a' + }) + // mismatch input and discipline actual = createGradeObject('V4', sanitizeDisciplines({ trad: true }), context) expect(actual).toBeUndefined() @@ -95,6 +102,11 @@ describe('Test grade utilities', () => { wi: 'WI4+' }) + actual = createGradeObject('17', sanitizeDisciplines({ deepwatersolo: true }), context) + expect(actual).toEqual({ + ewbank: '17' + }) + // Invalid input actual = createGradeObject('5.9', sanitizeDisciplines({ sport: true }), context) expect(actual).toBeUndefined() @@ -119,6 +131,11 @@ describe('Test grade utilities', () => { wi: 'WI6' }) + actual = createGradeObject('7c+', sanitizeDisciplines({ deepwatersolo: true }), context) + expect(actual).toEqual({ + french: '7c+' + }) + // Invalid input actual = createGradeObject('5.9', sanitizeDisciplines({ bouldering: true }), context) expect(actual).toBeUndefined() diff --git a/src/db/AreaSchema.ts b/src/db/AreaSchema.ts index 9cce8361..e27ded05 100644 --- a/src/db/AreaSchema.ts +++ b/src/db/AreaSchema.ts @@ -73,6 +73,7 @@ export const CountByDisciplineSchema = new Schema({ trad: { type: DisciplineStatsSchema, required: false }, sport: { type: DisciplineStatsSchema, required: false }, bouldering: { type: DisciplineStatsSchema, required: false }, + deepwatersolo: { type: DisciplineStatsSchema, required: false }, alpine: { type: DisciplineStatsSchema, required: false }, snow: { type: DisciplineStatsSchema, required: false }, ice: { type: DisciplineStatsSchema, required: false }, diff --git a/src/db/AreaTypes.ts b/src/db/AreaTypes.ts index 37bb9240..36fc5c15 100644 --- a/src/db/AreaTypes.ts +++ b/src/db/AreaTypes.ts @@ -189,6 +189,7 @@ export interface CountByDisciplineType { trad?: DisciplineStatsType sport?: DisciplineStatsType bouldering?: DisciplineStatsType + deepwatersolo?: DisciplineStatsType alpine?: DisciplineStatsType snow?: DisciplineStatsType ice?: DisciplineStatsType diff --git a/src/db/ClimbTypes.ts b/src/db/ClimbTypes.ts index 7c9769fa..b17db6a9 100644 --- a/src/db/ClimbTypes.ts +++ b/src/db/ClimbTypes.ts @@ -103,6 +103,8 @@ export interface DisciplineType { sport?: boolean /** https://en.wikipedia.org/wiki/Bouldering */ bouldering?: boolean + /** https://en.wikipedia.org/wiki/Deep-water_soloing */ + deepwatersolo?: boolean /** https://en.wikipedia.org/wiki/Alpine_climbing */ alpine?: boolean /** https://en.wikipedia.org/wiki/Ice_climbing */ diff --git a/src/db/export/Typesense/Utils.ts b/src/db/export/Typesense/Utils.ts index c259eb88..2165d0ae 100644 --- a/src/db/export/Typesense/Utils.ts +++ b/src/db/export/Typesense/Utils.ts @@ -7,6 +7,7 @@ export interface IFlatClimbTypes { typeTrad: boolean typeTR: boolean typeBouldering: boolean + typeDeepWaterSolo: boolean typeMixed: boolean typeAlpine: boolean typeSnow: boolean @@ -20,6 +21,7 @@ export const flattenDisciplines = (type: DisciplineType): IFlatClimbTypes => { typeTrad: type?.trad ?? false, typeTR: type?.tr ?? false, typeBouldering: type?.bouldering ?? false, + typeDeepWaterSolo: type?.deepwatersolo ?? false, typeMixed: type?.mixed ?? false, typeAlpine: type?.alpine ?? false, typeSnow: type?.snow ?? false, diff --git a/src/graphql/schema/Area.gql b/src/graphql/schema/Area.gql index a9dc82c5..ae13ae03 100644 --- a/src/graphql/schema/Area.gql +++ b/src/graphql/schema/Area.gql @@ -126,6 +126,7 @@ type CountByDisciplineType { sport: DisciplineStatsType bouldering: DisciplineStatsType boulder: DisciplineStatsType @deprecated(reason: "Migrating to 'bouldering'") + deepwatersolo: DisciplineStatsType alpine: DisciplineStatsType snow: DisciplineStatsType ice: DisciplineStatsType diff --git a/src/graphql/schema/Climb.gql b/src/graphql/schema/Climb.gql index ffe57db5..d767d73b 100644 --- a/src/graphql/schema/Climb.gql +++ b/src/graphql/schema/Climb.gql @@ -110,6 +110,8 @@ type ClimbType { sport: Boolean "https://en.wikipedia.org/wiki/Bouldering" bouldering: Boolean + "https://en.wikipedia.org/wiki/Deep-water_soloing" + deepwatersolo: Boolean "https://en.wikipedia.org/wiki/Alpine_climbing" alpine: Boolean "https://en.wikipedia.org/wiki/Ice_climbing" diff --git a/src/graphql/schema/ClimbEdit.gql b/src/graphql/schema/ClimbEdit.gql index a82284b6..8ec92446 100644 --- a/src/graphql/schema/ClimbEdit.gql +++ b/src/graphql/schema/ClimbEdit.gql @@ -52,6 +52,8 @@ input DisciplineType { sport: Boolean "https://en.wikipedia.org/wiki/Bouldering" bouldering: Boolean + "https://en.wikipedia.org/wiki/Deep-water_soloing" + deepwatersolo: Boolean "https://en.wikipedia.org/wiki/Alpine_climbing" alpine: Boolean "https://en.wikipedia.org/wiki/Ice_climbing" diff --git a/src/model/__tests__/MutableClimbDataSource.ts b/src/model/__tests__/MutableClimbDataSource.ts index 140b8cc6..525dfc83 100644 --- a/src/model/__tests__/MutableClimbDataSource.ts +++ b/src/model/__tests__/MutableClimbDataSource.ts @@ -39,6 +39,12 @@ describe('Climb CRUD', () => { location: '5m left of the big tree', protection: '5 quickdraws' }, + { + name: 'Deep water 1', + disciplines: { + deepwatersolo: true + } + }, { name: 'Cool trad one', disciplines: {