Skip to content

Commit

Permalink
Hide session template in developer metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
tidoust committed Jan 8, 2025
1 parent 073963e commit 5ffe015
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tools/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ program
.action(getProjectCommandRunner(synchronizeSheet))
.addHelpText('after', `
Notes:
- Local environment must define a \`GOOGLE_KEY_JSON\` variable.
The variable must complete the path to a JSON file that contains the
- Local environment must define a \`GOOGLE_KEY_FILE\` variable.
The variable must be the path to a JSON file that contains the
private key of a service account with the appropriate rights, created
in Google Cloud: https://console.cloud.google.com/.
Expand Down
1 change: 1 addition & 0 deletions tools/node/lib/project.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ export async function fetchProject(login, id) {
allowRegistrants: !!registrants?.id,

// Sections defined in the issue template
sessionTemplate: templateYaml,
sessionSections,

// List of open sessions linked to the project (in other words, all of the
Expand Down
55 changes: 54 additions & 1 deletion tools/node/lib/project2sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ export async function convertProjectToSheet(project,
desc.sheetId = sheet.properties.sheetId;
desc.title = sheet.properties.title;
}
if (name === 'sessions') {
const devMetadata = res.data.developerMetadata?.find(d =>
d.metadataKey === 'session-template');
if (devMetadata) {
desc.sessionTemplate = devMetadata.metadataValue;
}
}
}
}

Expand Down Expand Up @@ -737,6 +744,51 @@ export async function convertProjectToSheet(project,
});
}

/**
* The YAML session template is stored as developer metadata in the
* spreadsheet.
*
* Note: the function assumes that no one else will mess up with developer
* metadata (and, e.g., create another "session-template" key with a
* different location)
*/
async function updateSessionTemplate() {
let request;
if (sheetsInfo.sessions.sessionTemplate) {
request = {
updateDeveloperMetadata: {
dataFilters: [
{
developerMetadataLookup: {
metadataKey: 'session-template'
}
}
],
developerMetadata: {
metadataValue: project.sessionTemplate
},
fields: 'metadataValue'
}
};
}
else {
request = {
createDeveloperMetadata: {
developerMetadata: {
metadataKey: 'session-template',
metadataValue: project.sessionTemplate,
location: { spreadsheet: true },
visibility: 'DOCUMENT'
}
}
};
}
await sheets.spreadsheets.batchUpdate({
spreadsheetId,
resource: { requests: [request] }
});
}

// Create the spreadsheet if needed
if (!spreadsheetId) {
spreadsheetId = await createSpreadsheet();
Expand All @@ -749,8 +801,9 @@ export async function convertProjectToSheet(project,
await updateSlots();
await updateSessions();
await updateMeetings();
await updateSessionTemplate();

/*res = await sheets.spreadsheets.get({
/*const res = await sheets.spreadsheets.get({
spreadsheetId,
includeGridData: true
});
Expand Down

0 comments on commit 5ffe015

Please sign in to comment.