Closed YUUU23 closed 1 month ago
Visit the preview URL for this PR (updated for commit 58fceba):
https://ccv-honeycomb--pr517-add-cli-register-10x1mzbw.web.app
(expires Thu, 22 Aug 2024 01:39:15 GMT)
🔥 via Firebase Hosting GitHub Action 🌎
Sign: 4ace1dcea913a952d2a1af84b94a4421bf36e610
This is great! Could you create a new study and add some participants using the CLI and then send a few screenshots here? Just to confirm everything is looking good
Also, @YUUU23 could you set the base of this to be add-commander? It looks like it'll rebase fairly smoothly
This is great! Could you create a new study and add some participants using the CLI and then send a few screenshots here? Just to confirm everything is looking good
(base) happy2na@TheHappy2Na-229 honeycomb % npm run cli register test p3
honeycomb@4.0.0 cli node cli.mjs register test p3
register data from Firebase given study ID: test and participant ID: p3 ? Currently, there are no participants under this study Continue? adding study with studyID: test and participant ID: p3 yes Successfully added study and participant. Current participantIDs under study test: p3
<img width="1097" alt="image" src="https://github.com/user-attachments/assets/b24dcac6-bd94-46a5-9e09-a47d2d93730e">
- **Adding new participant under existing study**
(base) happy2na@TheHappy2Na-229 honeycomb % npm run cli register test p4
honeycomb@4.0.0 cli node cli.mjs register test p4
register data from Firebase given study ID: test and participant ID: p4 ? Currently, the participants under this study include: p3 Continue? adding study with studyID: test and participant ID: p4 yes Successfully added study and participant. Current participantIDs under study test: p3 p4
<img width="1079" alt="image" src="https://github.com/user-attachments/assets/b915448f-4313-4c5d-84aa-77b57fce047d">
- **Without providing optional participant**
(base) happy2na@TheHappy2Na-229 honeycomb % npm run cli register test2
honeycomb@4.0.0 cli node cli.mjs register test2
register data from Firebase given study ID: test2 ? Enter a new participant: p1 ? Currently, there are no participants under this study Continue? adding study with studyID: test2 and participant ID: p1 yes Successfully added study and participant. Current participantIDs under study test2: p1
<img width="1083" alt="image" src="https://github.com/user-attachments/assets/95345de3-0696-468c-be7b-8cdee1bb591c">
- **Entirely through prompt**
(base) happy2na@TheHappy2Na-229 honeycomb % npm run cli
honeycomb@4.0.0 cli node cli.mjs
? What would you like to do? Register new participant under study ? Select a study: test2 ? Enter a new participant: p0 ? Currently, the participants under this study include: p1 Continue? adding study with studyID: test2 and participant ID: p0 yes Successfully added study and participant. Current participantIDs under study test2: p1 p0
<img width="1074" alt="image" src="https://github.com/user-attachments/assets/13e5fabb-3485-4904-8482-e2b96b9efd8c">
We will not have cases where the study is not found, since it will register the new study if not found.
Add
register
to commander, permitting script to be optionally ran withregister
(i.e.npm run cli register [studyID][partipantID]
, skipping prompt first, second, and third prompt when those relative arguments are providedmain()
:ACTION == "register"
):actionPrompt()
: Add choice for registering new study & participantsstudyIDPrompt()
: Directly setSTUDY_ID
to the input read in and returnparticipantIDPrompt()
: Directly setPARTICIPANT_ID
to the input read in and return, modify prompt to ask for "Enter a new participant:"experimentIDPrompt()
: Skip this prompt, directly returnregister
, calling functionregisterDataFirebase(studyID, participantID)
to register the new study in FirestoreconfirmRegisterPrompt()
: prints out current participant IDs under study if there are any (else print message saying there are none) and ask user to confirm that they want to add the new IDs inAdd new variable
const REG_STUDY_COL = "registered_studies";
for the top-level collection we want to access when registeringregisterDataFirebase(studyID, participantID)
:Helper Functions:
getRegisteredfStudyRef(studyID)
: get reference to the study in"registered_studies"
getRegisteredParticipantArr(studyID)
: return empty array if the current study is not initiated yet; else return array of all participant IDs under given studyregisterNewParticipant(studyID, participantID)
: if there's aregistered_participants
array started under the registered study, add the new participantID to the array and update in FirestoreNow, direct firestore editing instructions outlined here: https://honeycomb.ccv.brown.edu/docs/firebase#registering-studies may be completed through CLI