-
-
Notifications
You must be signed in to change notification settings - Fork 32
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: add multipitch support #350
Conversation
l4u532's UIAA changes
@musoke Would you kindly have a look? Thank you =) |
8ea30d3
to
4ce0c36
Compare
@l4u532 I'll have a look at this issue by this weekend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to reread #266 to remind myself of all the nuances discussed previously. This looks good, although I haven't run it myself.
We discussed allowing a pitch to be part of multiple routes, to account for variations, etc. Does this PR allow for that to be added in future? The number
and parent
fields assume only one parent route.
src/db/ClimbSchema.ts
Outdated
default: function () { return this._id.toString() } | ||
}, | ||
parentId: { type: String, required: true }, | ||
number: { type: Number, required: true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is number? Is this to track the order of the pitches?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it from the rest of the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
number
is to track the sequence of pitches. It is also only required field besides id
and parentId
. The reasoning: the correct sequence of information is essential for multi-pitches. A user might only add the pitches' grades
; but it is prime that she does so in correct order, else the value of information is almost zero.
Since this seems to be non-intuitive, should I rename this field for more clarity? E. g. pitchNumber
? (Suggestions welcome)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use something else besides number
to avoid conflict with number
in Typescript. pitchNumber
sounds good. At first I thought pitch number isn't needed since we can get them from the array index. But in some case it may not be easy to get the index. Glad you thought of it.
See #350 (comment) for my reply. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@l4u532 Thank you very much for this PR, and I apologize for my delayed response. I left my feedback inline.
src/db/ClimbSchema.ts
Outdated
default: function () { return this._id.toString() } | ||
}, | ||
parentId: { type: String, required: true }, | ||
number: { type: Number, required: true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use something else besides number
to avoid conflict with number
in Typescript. pitchNumber
sounds good. At first I thought pitch number isn't needed since we can get them from the array index. But in some case it may not be easy to get the index. Glad you thought of it.
src/db/ClimbSchema.ts
Outdated
boltsCount: { type: Number }, | ||
description: { type: String } | ||
}, { | ||
_id: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should remove _id: true
since we will be providing our own UUID. _id: true
means Mongo will auto-generate _id for us in ObjectID format (not UUID).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vnugent I have incorporated all changes and would be happy to get your re-review, especially on lines 77-81, since I am not sure if I have interpreted your suggestions correctly: https://github.com/OpenBeta/openbeta-graphql/pull/350/files#diff-9b4028942ce1d106899ff51138cc6ee7cc75ea36110257394c51424643261967R77-R81
2ca8e03
to
4fd8509
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updating the code. I think we're very close now. I left some comments inline.
4fd8509
to
b223a67
Compare
Incorporated the requested changes. FYI, there is a phenomenon which I do not yet quite understand. I assume its harmless. When updating pitches, "id" is added - additionally to "_id":
|
As mentioned the spread operator Once you fix that, we're good to merge. I think we may need to create an additional create/update/delete pitch API to make it easier to work with pitch data. |
b223a67
to
dfb24d9
Compare
Sorry for the belated fix, I was on vacation. I am kindly asking you to review this hopefully final fix :) @vnugent |
I'm traveling at the moment. Will get back to you by next week. |
Problem
(See #266)
For a given multi-pitch climb, for each pitch, we want to represent multiple boltsCount and grades, e. g. grade = ["6a", "6c", "5c", "6c"], and boltsCount = [4, 6, 3, 3], and possible other data (like description).
Solution
Introduce type
Pitch
(with fieldsparentId
,type
,number
,grade
,length
,boltsCount
,description
) as a child toclimb
, so thatclimb
gets an optional ArrayClimb.pitches
containing each pitch; this has the most flexibility and allows for detailed per-pitch data, plus it wouldn't break any existing implementationExample JSON Doc Schema
The Type
Pitch
would contain: