-
Notifications
You must be signed in to change notification settings - Fork 8
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
add: commander to optionally provide delete or download along with st… #516
Conversation
…udyID and participantID to cmd line
Visit the preview URL for this PR (updated for commit 1cc9e92): https://ccv-honeycomb--pr516-add-commander-9itykqix.web.app (expires Wed, 21 Aug 2024 06:47:16 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 4ace1dcea913a952d2a1af84b94a4421bf36e610 |
…functions to use to check if arguments passed into CLI directly when running delete and download are valid
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.
Looking great! There's just a couple small changes as far as the code style
cli.mjs
Outdated
}; | ||
// subcollection is programmatically generated, if it doesn't exist then input must not be a valid studyID | ||
const studyIDCollections = await getStudyRef(input).listCollections(); | ||
return studyIDCollections.find((c) => c.id === PARTICIPANTS_COL) ? true : invalidMessage; |
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.
Hmm... I know this is code I wrote but it looks a little funky to me. Are you okay changing it here?
I would return true
or false
from this function and then in main
where you have that console.error
I would just call the string itself - console.error("Please enter a valid study from your Firestore database")
Actually @YUUU23 can you test what this PR would look like if merging into |
It seems like all the forward commits for v4 features would also be on this branch to be merged into 3.4.2. Do you know if it's possible to rebase on a branch with less features that would delete those v4 features 3.4.2 doesn't have? Otherwise, I think I can also move the CLI script code into a new branch based off of 3.4.2 and open a new PR since the CLI code are all in one file. |
…into add-commander
…honeycomb into add-commander" This reverts commit c48f5d6, reversing changes made to c2ec9eb.
To have this in writing - let's leave it as a change for v4 for right now. Eventually we will release the version and we can include a quick write up for bringing the CLI script into older versions of Honeycomb |
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.
Looking good! Just some organizational changes from here!
cli.mjs
Outdated
// helper to check if the given study (input) is in firestore | ||
async function validateStudyFirebase(input) { | ||
// subcollection is programmatically generated, if it doesn't exist then input must not be a valid studyID | ||
const studyIDCollections = await getStudyRef(input).listCollections(); | ||
return studyIDCollections.find((c) => c.id === PARTICIPANTS_COL); | ||
} |
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.
Can you move this helper function (along with validateParticipantFirebase
) into a new section for validation functions? It looks like some of the comments aren't above the correct functions anymore
cli.mjs
Outdated
/** Prompt the user to enter the ID of a participant on the STUDY_ID study */ | ||
// helper to check if the given participant (input) is in firestore under study |
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.
Yeah, it looks like the comment on line 269 is for the function defined on line 277
cli.mjs
Outdated
const res = await validateStudyFirebase(input); | ||
return !res ? invalidMessage : 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're calling .find
inside validateStudyFirebase
so I would rename this to be studyCollection
or something like that? Because the return of the function is really the Firebase study collection or undefined
Co-authored-by: Robert Gemma <[email protected]>
Co-authored-by: Robert Gemma <[email protected]>
Co-authored-by: Robert Gemma <[email protected]>
Co-authored-by: Robert Gemma <[email protected]>
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 commented to simplify some logical expressions. Looks like Rob reviewed this quite a bit ! Small changes, otherwise looks good to go !
Co-authored-by: Ellen Duong <[email protected]>
Co-authored-by: Ellen Duong <[email protected]>
Thank you so much for reviewing this!! |
Reverted changes |
commander
and initialize commander to be usedmain()
as before, all prompts will be askedmain()
if not (validating functions originally in prompt functions are pulled out for this purpose)npm run cli download [study ID] [participant ID]
ornpm run cli delete [study ID] [participant ID]
, relative global variables (ACTION
,STUDY_ID
,PARTICIPANT_ID
) are set to what's provided through command line input, skipping those prompts since we have a value assigned to the global variables alreadyI accidentally pushed the code to the actual
feat-v4
branch, but I reverted this commit (now in this PR)! Sorry about this