Skip to content

Commit

Permalink
feat: add Repeat option for ticks
Browse files Browse the repository at this point in the history
  • Loading branch information
glassbead0 authored and vnugent committed Feb 24, 2025
1 parent 97036cc commit a849323
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
9 changes: 5 additions & 4 deletions documentation/tick_logic.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Here are all the possible values for `Climb.type` (also called discipline), as d
| snow | Aid | Send |
| ice | Boulder | Attempt |
| aid | | Frenchfree |
| tr | | |
| tr | | Repeat |
| alpine | | |
| mixed | | |

Expand Down Expand Up @@ -55,10 +55,10 @@ Since a route can have multiple disciplines, these options are composable. eg: a

| Tick Style | Attempt Type options |
|------------|----------------------|
| 'Lead' | 'Onsight', 'Flash', 'Redpoint', 'Pinkpoint', 'Attempt', 'Frenchfree' |
| 'Lead' | 'Onsight', 'Flash', 'Redpoint', 'Pinkpoint', 'Attempt', 'Frenchfree', 'Repeat' |
| 'Follow', 'TR' or 'Aid | 'Send', 'Attempt' |
| 'Solo' | 'Onsight', 'Flash', 'Redpoint', 'Attempt' |
| 'Boulder' | 'Flash', 'Send', 'Attempt' |
| 'Solo' | 'Onsight', 'Flash', 'Redpoint', 'Attempt', 'Repeat' |
| 'Boulder' | 'Flash', 'Send', 'Attempt', 'Repeat' |

## A few justifications

Expand All @@ -68,6 +68,7 @@ Since a route can have multiple disciplines, these options are composable. eg: a
* While 'Frenchfree' and 'Aid' could be considered synomonous, some climbers may want to distinguish, for example, a multipitch route where one pitch was intentionally 'French freed' (Time Wave Zero being a common example), which is distinctly different in character than, eg: aiding the Nose on El Cap.
* Eventually, it might be cool to allow ticks for individual pitches, but that is not supported right now.
* Given the 43,008 possible combinations, no simple logical system will perfectly capture every edge case.
* Repeats: routes can be "repeated" after they are sent. this generally only applies if you have previously sent a route or boulder cleanly, and you send the route/boulder again cleanly. This is not typically used, for example, to mark additional attempts on a route that you haven't cleanly sent yet (one would use "attempt" for that). The only `Tick Style`s, for which `Repeat` is not allowed is `Follow` `TR` and `Aid`. While aid routes may be repeated, this is a rare enough use case and simplifies the logic in the code.


## Importing from Mountain Project
Expand Down
2 changes: 1 addition & 1 deletion src/db/TickSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const TickSchema = new Schema<TickType>({
climbId: { type: Schema.Types.String, required: true, index: true },
userId: { type: Schema.Types.String, required: true, index: true },
style: { type: Schema.Types.String, enum: ['Lead', 'Solo', 'TR', 'Follow', 'Aid', 'Boulder'], required: false },
attemptType: { type: Schema.Types.String, enum: ['Onsight', 'Flash', 'Pinkpoint', 'Frenchfree', 'Redpoint', 'Send', 'Attempt'], required: false, index: true },
attemptType: { type: Schema.Types.String, enum: ['Onsight', 'Flash', 'Pinkpoint', 'Frenchfree', 'Redpoint', 'Send', 'Attempt', 'Repeat'], required: false, index: true },
dateClimbed: { type: Schema.Types.Date },
grade: { type: Schema.Types.String, required: false, index: true },
// Bear in mind that these enum types must be kept in sync with the TickSource enum
Expand Down
4 changes: 2 additions & 2 deletions src/db/TickTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export type TickSource =
'MP'

export type TickStyle = 'Lead' | 'Solo' | 'TR' | 'Follow' | 'Aid' | 'Boulder'
export type TickAttemptType = 'Onsight' | 'Flash' | 'Pinkpoint' | 'Frenchfree' | 'Send' | 'Attempt' | 'Redpoint'
export type TickAttemptType = 'Onsight' | 'Flash' | 'Pinkpoint' | 'Frenchfree' | 'Send' | 'Attempt' | 'Redpoint' | 'Repeat'

export const TickSourceValues: TickSource[] = ['OB', 'MP']
export const TickStyleValues: TickStyle[] = ['Lead', 'Solo', 'TR', 'Follow', 'Aid', 'Boulder']
export const TickAttemptTypeValues: TickAttemptType[] = ['Onsight', 'Flash', 'Pinkpoint', 'Frenchfree', 'Send', 'Attempt', 'Redpoint']
export const TickAttemptTypeValues: TickAttemptType[] = ['Onsight', 'Flash', 'Pinkpoint', 'Frenchfree', 'Send', 'Attempt', 'Redpoint', 'Repeat']

/** Ticks
* Ticks represent log entries for a user's climbing activity. They contain
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/schema/Tick.gql
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ enum TickAttemptType {
Send
"Redpoint"
Redpoint
"Repeat"
Repeat
}

enum TickStyle {
Expand Down
6 changes: 3 additions & 3 deletions src/model/TickDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,17 @@ export default class TickDataSource extends MongoDataSource<TickType> {
// validate attempt type for each tick style
switch (tickStyle) {
case 'Lead':
if (!['Onsight', 'Flash', 'Redpoint', 'Pinkpoint', 'Attempt', 'Frenchfree', 'null'].includes(attemptType)) {
if (!['Onsight', 'Flash', 'Redpoint', 'Pinkpoint', 'Attempt', 'Frenchfree', 'Repeat', 'null'].includes(attemptType)) {
throw new Error(`Invalid attempt type ${attemptType} for Lead style`)
}
break
case 'Solo':
if (!['Onsight', 'Flash', 'Redpoint', 'Attempt', 'null'].includes(attemptType)) {
if (!['Onsight', 'Flash', 'Redpoint', 'Attempt', 'Repeat', 'null'].includes(attemptType)) {
throw new Error(`Invalid attempt type ${attemptType} for Solo style`)
}
break
case 'Boulder':
if (!['Flash', 'Send', 'Attempt', 'null'].includes(attemptType)) {
if (!['Flash', 'Send', 'Attempt', 'Repeat', 'null'].includes(attemptType)) {
throw new Error(`Invalid attempt type ${attemptType} for Boulder style`)
}
break
Expand Down

0 comments on commit a849323

Please sign in to comment.