Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Deep water solo discipline #269

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
17 changes: 17 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 Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
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 @@ -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: {
Expand Down