-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Try me out" field mechanism to try schedule updates (#120)
This adds a new `try-changes` command that tries schedule updates defined in a "Try me out" field, as discussed in #115. The optional `--apply` flag tells the command to apply the adjusted schedule. Applying the adjusted schedule resets the "Try me out" fields. The command is restricted to group meetings for now. Running it on projects that do not define a "Meeting" field will not work.
- Loading branch information
Showing
5 changed files
with
126 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { validateGrid } from '../lib/validate.mjs'; | ||
import { saveSessionMeetings } from '../lib/project.mjs'; | ||
import { convertProjectToHTML } from '../lib/project2html.mjs'; | ||
|
||
export default async function (project, options) { | ||
if (!project.allowTryMeOut) { | ||
throw new Error(`No "Try me out" custom field in project`); | ||
} | ||
|
||
if (!project.sessions.find(session => session.trymeout)) { | ||
throw new Error(`No schedule adjustments to try!`); | ||
} | ||
|
||
console.warn(); | ||
console.warn(`Adjust schedule with "Try me out" field...`); | ||
for (const session of project.sessions) { | ||
if (session.trymeout) { | ||
// TODO: also support "try me out" for breakout sessions, | ||
// updating the room, day and slot fields instead of meeting which | ||
// does not exist for breakout sessions. | ||
session.meeting = session.trymeout; | ||
session.trymeout = null; | ||
session.updated = true; | ||
console.warn(`- session ${session.number}: from "${session.meeting}" to "${session.trymeout}"`); | ||
} | ||
} | ||
console.warn(`Adjust schedule with "Try me out" field... done`); | ||
|
||
console.warn(); | ||
console.warn(`Validate created grid...`); | ||
const { errors: newErrors } = await validateGrid(project, { what: 'scheduling' }) | ||
if (newErrors.length) { | ||
for (const error of newErrors) { | ||
console.warn(`- [${error.severity}: ${error.type}] #${error.session}: ${error.messages.join(', ')}`); | ||
} | ||
} | ||
else { | ||
console.warn(`- looks good!`); | ||
} | ||
console.warn(`Validate created grid... done`); | ||
|
||
console.warn(); | ||
console.warn(`Report project as HTML...`); | ||
const html = await convertProjectToHTML(project); | ||
console.warn(); | ||
console.log(html); | ||
console.warn(`Report project as HTML... done`); | ||
|
||
if (options.apply) { | ||
console.warn(); | ||
console.warn(`Apply created grid...`); | ||
const sessionsToUpdate = project.sessions.filter(s => s.updated); | ||
for (const session of sessionsToUpdate) { | ||
console.warn(`- updating #${session.number}...`); | ||
await saveSessionMeetings(session, project); | ||
console.warn(`- updating #${session.number}... done`); | ||
} | ||
console.warn(`Apply created grid... done`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters