Skip to content

Commit

Permalink
feat: Deep water solo discipline
Browse files Browse the repository at this point in the history
  • Loading branch information
musoke committed Jun 1, 2023
1 parent fb7bf62 commit 084a0aa
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/GradeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const gradeContextToGradeScales: Partial<Record<GradeContexts, ClimbGrade
sport: GradeScales.EWBANK,
bouldering: GradeScales.VSCALE,
tr: GradeScales.EWBANK,
deepwatersolo: GradeScales.EWBANK,
alpine: GradeScales.YDS,
mixed: GradeScales.YDS,
aid: GradeScales.YDS,
Expand All @@ -53,6 +54,7 @@ export const gradeContextToGradeScales: Partial<Record<GradeContexts, ClimbGrade
sport: GradeScales.YDS,
bouldering: GradeScales.VSCALE,
tr: GradeScales.YDS,
deepwatersolo: GradeScales.YDS,
alpine: GradeScales.YDS,
mixed: GradeScales.YDS,
aid: GradeScales.YDS,
Expand All @@ -64,6 +66,7 @@ export const gradeContextToGradeScales: Partial<Record<GradeContexts, ClimbGrade
sport: GradeScales.FRENCH,
bouldering: GradeScales.FONT,
tr: GradeScales.FRENCH,
deepwatersolo: GradeScales.FRENCH,
alpine: GradeScales.FRENCH,
mixed: GradeScales.FRENCH,
aid: GradeScales.FRENCH,
Expand All @@ -75,6 +78,7 @@ export const gradeContextToGradeScales: Partial<Record<GradeContexts, ClimbGrade
sport: GradeScales.FRENCH,
bouldering: GradeScales.FONT,
tr: GradeScales.FRENCH,
deepwatersolo: GradeScales.FRENCH,
alpine: GradeScales.FRENCH,
mixed: GradeScales.FRENCH,
aid: GradeScales.FRENCH,
Expand Down Expand Up @@ -205,7 +209,7 @@ export const getCountriesDefaultGradeContext = (): { [x: string]: GradeContexts
return countries
}

export const validDisciplines = ['trad', 'sport', 'bouldering', 'alpine', 'snow', 'ice', 'mixed', 'aid', 'tr']
export const validDisciplines = ['trad', 'sport', 'bouldering', 'deepwatersolo', 'alpine', 'snow', 'ice', 'mixed', 'aid', 'tr']

/**
* Perform runtime validation of climb discipline object
Expand Down Expand Up @@ -234,6 +238,7 @@ export const defaultDisciplines = (): DisciplineType => ({
trad: false,
sport: false,
bouldering: false,
deepwatersolo: false,
alpine: false,
snow: false,
ice: false,
Expand Down
12 changes: 12 additions & 0 deletions src/__tests__/gradeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('Test grade utilities', () => {
trad: true,
sport: false,
bouldering: false,
deepwatersolo: false,
alpine: false,
snow: false,
ice: false,
Expand All @@ -28,6 +29,7 @@ describe('Test grade utilities', () => {
trad: false,
sport: false,
bouldering: true,
deepwatersolo: false,
alpine: false,
snow: false,
ice: false,
Expand All @@ -52,6 +54,11 @@ describe('Test grade utilities', () => {
vscale: 'V4'
})

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()
Expand Down Expand Up @@ -94,6 +101,11 @@ describe('Test grade utilities', () => {
font: '7c'
})

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()
Expand Down
1 change: 1 addition & 0 deletions src/db/AreaSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const CountByDisciplineSchema = new Schema<CountByDisciplineType>({
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 },
Expand Down
1 change: 1 addition & 0 deletions src/db/AreaTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export interface CountByDisciplineType {
trad?: DisciplineStatsType
sport?: DisciplineStatsType
bouldering?: DisciplineStatsType
deepwatersolo?: DisciplineStatsType
alpine?: DisciplineStatsType
snow?: DisciplineStatsType
ice?: DisciplineStatsType
Expand Down
2 changes: 2 additions & 0 deletions src/db/ClimbTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 2 additions & 0 deletions src/db/export/Typesense/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface IFlatClimbTypes {
typeTrad: boolean
typeTR: boolean
typeBouldering: boolean
typeDeepWaterSolo: boolean
typeMixed: boolean
typeAlpine: boolean
typeSnow: boolean
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/graphql/schema/Area.gql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/schema/Climb.gql
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/schema/ClimbEdit.gql
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions src/model/__tests__/MutableClimbDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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: {
Expand Down

0 comments on commit 084a0aa

Please sign in to comment.