Skip to content

Commit

Permalink
fix: use Lead Style from MP tick import instead of Style
Browse files Browse the repository at this point in the history
* set style and attemptType to null instead of N/A if absent
* convert 'Fell/Hung' to 'Attempt' since thats what OB uses
* add .tool-versions to gitignore for anyone using asdf
  • Loading branch information
glassbead0 committed Jan 25, 2025
1 parent 970a113 commit 010ed46
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,8 @@ content
*.pem
.vscode/launch.json

# for anyone using asdf
.tool-versions

.lighthouseci
.idea/
20 changes: 16 additions & 4 deletions src/app/api/user/bulkImportTicks/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export interface Tick {
notes: string
climbId: string
userId: string | undefined
style: string
attemptType: string
style: string | null
attemptType: string | null
dateClimbed: Date
grade: string
source: string
Expand All @@ -39,6 +39,18 @@ function extractId (mpUrl: string): string | Number {
}
}

// The main difference b/t MP and OB is we use 'Attempt' instead of 'Fell/Hung'. Also handle's empty string (converts to null)
function convertMPattemptType (leadStyle: string): string | null {
switch (leadStyle) {
case '':
return null
case 'Fell/Hung':
return 'Attempt'
default:
return leadStyle
}
}

interface MPTick {
mp_id: string // We extract this from the URL -- not supplied in MP's CSV.
Date: string
Expand Down Expand Up @@ -99,8 +111,8 @@ const postHandler = async (req: NextRequest): Promise<any> => {
notes: tick.Notes,
climbId: tick.mp_id,
userId: uuid,
style: tick.Style === '' ? 'N/A' : tick.Style,
attemptType: tick.Style === '' ? 'N/A' : tick.Style,
style: tick.Style === '' ? null : tick.Style,
attemptType: convertMPattemptType(tick['Lead Style']),
dateClimbed: new Date(Date.parse(`${tick.Date}T00:00:00`)), // Date.parse without timezone specified converts date to user's present timezone.
grade: tick.Rating,
source: 'MP'
Expand Down

0 comments on commit 010ed46

Please sign in to comment.