Skip to content

Commit

Permalink
Add new "view-registrants" CLI command, replaces "assess-room-capacit…
Browse files Browse the repository at this point in the history
…y" (#168)

The new command replaces the "assess-room-capacity" command and lets one
visualize the number of participants and observers of sessions, and generate a
report with sessions in large enough rooms, in rooms that are too small due to
the number of participants, and in rooms that are too small due to the number
of observers.

The numbers of registrants are retrieved from a `Registrants` custom field in
the project.

Command options make it possible to:
1. Fetch updated numbers from a registrants page (for TPAC events).
2. Update these numbers in the project's `Registrants` custom field.
3. Restrict the output to warnings (rooms too small)
  • Loading branch information
tidoust authored Sep 13, 2024
1 parent 61db8d1 commit 2542401
Show file tree
Hide file tree
Showing 5 changed files with 316 additions and 205 deletions.
12 changes: 12 additions & 0 deletions test/stubs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ async function getTestData(testDataId) {
field: { name: 'Try me out' }
});
}
if (session.registrants) {
fields.push({
text: session.registrants,
field: { name: 'Registrants' }
});
}

return {
id: `id_${uid++}`,
Expand Down Expand Up @@ -148,6 +154,9 @@ async function getTestData(testDataId) {
if (custom.allowTryMeOut) {
testData.allowTryMeOut = custom.allowTryMeOut;
}
if (custom.allowRegistrants) {
testData.allowRegistrants = custom.allowRegistrants;
}

testDataCache[testDataId] = testData;
return JSON.parse(JSON.stringify(testData));
Expand Down Expand Up @@ -182,6 +191,9 @@ export async function sendGraphQLRequest(query, acceptHeader = '') {
else if ((name === 'Try me out') && !testData.allowTryMeOut) {
field = null;
}
else if ((name === 'Registrants') && !testData.allowRegistrants) {
field = null;
}
else {
field = {
id: `id_field_${name}`,
Expand Down
25 changes: 15 additions & 10 deletions tools/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import schedule from './commands/schedule.mjs';
import synchronizeCalendar from './commands/sync-calendar.mjs';
import validate from './commands/validate.mjs';
import viewEvent from './commands/view-event.mjs';
import viewRegisrants from './commands/view-registrants.mjs';
import tryChanges from './commands/try-changes.mjs';
import assessRoomsCapacity from './commands/assess-rooms-capacity.mjs';


/**
Expand Down Expand Up @@ -238,19 +238,24 @@ Examples:


/******************************************************************************
* The "assess-rooms" command
* The "view-registrants" command
*****************************************************************************/
program
.command('assess-rooms')
.summary('Assess assigned rooms capacity against the actual number of registrants for a TPAC event.')
.description('Assess assigned rooms capacity against the actual number of registrants for each meeting for a TPAC event.')
.argument('<number>', 'meeting rooms to assess. Either a group session number or "all" to assess all meeting rooms.')
.option('-u, --url <url>', 'URL of the page that lists the registrants per meeting. The code uses `https://www.w3.org/register/[meeting name]/registrants` when not given')
.action(getCommandRunner(assessRoomsCapacity))
.command('view-registrants')
.summary('View the number of participants and observers for each session.')
.description('View the number of participants and observers for each session, possibly fetching the information from a registrants page (for TPAC events).')
.argument('<number>', 'session to view. Either a session number or "all" to view information for all sessions.')
.option('-f, --fetch', 'fetch the registrants information from the registrants page.')
.option('-s, --save', 'save registrants information to the project. The --fetch option must be set.')
.option('-u, --url <url>', 'URL of the page that lists the registrants per session. The code uses `https://www.w3.org/register/[meeting name]/registrants` when not given. The --fetch option must be set.')
.option('-w, --warnings-only', 'Only return information about sessions that meet in rooms that are too small.')
.action(getCommandRunner(viewRegisrants))
.addHelpText('after', `
Examples:
$ npx tpac-breakouts assess-rooms all
$ npx tpac-breakouts assess-rooms 42
$ npx tpac-breakouts view-registrants all
$ npx tpac-breakouts view-registrants all -w
$ npx tpac-breakouts view-registrants all --fetch --save
$ npx tpac-breakouts view-registrants all --fetch --url https://example.org/registrants
`);


Expand Down
187 changes: 0 additions & 187 deletions tools/commands/assess-rooms-capacity.mjs

This file was deleted.

Loading

0 comments on commit 2542401

Please sign in to comment.