Skip to content

Commit e49793d

Browse files
committed
Fix calendar update trigger
1 parent c408268 commit e49793d

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

tools/appscript/export-grid.mjs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,22 @@ import {
77
fetchProjectFromGitHub,
88
saveSessionMeetings,
99
saveSessionNote } from '../common/project.mjs';
10+
import { getEnvKey } from '../common/envkeys.mjs';
1011
import { exportMapping } from './lib/w3cid-map.mjs';
1112
import { exportRoomZoom } from './lib/room-zoom.mjs';
1213

14+
/**
15+
* Mapping for day gets done on the name or date for historical reasons.
16+
*/
17+
function getDate(day) {
18+
if (day?.match(/ \((.+)\)$/)) {
19+
return day.match(/ \((.*)\)$/)[1];
20+
}
21+
else {
22+
return day ?? '';
23+
}
24+
}
25+
1326
export default async function () {
1427
try {
1528
console.log('Read data from spreadsheet...');
@@ -69,7 +82,7 @@ export default async function () {
6982
// TODO: handle meeting column for TPAC group meetings
7083

7184
if (((ghSession.room ?? '') !== (ssSession.room ?? '')) ||
72-
((ghSession.day ?? '') !== (ssSession.day ?? '')) ||
85+
(getDate(ghSession.day) !== getDate(ssSession.day)) ||
7386
((ghSession.slot ?? '') !== (ssSession.slot ?? ''))) {
7487
console.warn(`- updating meeting info for #${ghSession.number}...`);
7588
ghSession.room = ssSession.room;
@@ -100,8 +113,7 @@ export default async function () {
100113
await exportRoomZoom(project);
101114
console.log('Export ROOM_ZOOM variable to GitHub... done');
102115

103-
if (updated.length > 0 &&
104-
project.metadata.calendar &&
116+
if (project.metadata.calendar &&
105117
project.metadata.calendar !== 'no') {
106118
console.log('Trigger calendar publication...');
107119
const GRAPHQL_TOKEN = await getEnvKey('GRAPHQL_TOKEN');
@@ -124,6 +136,7 @@ export default async function () {
124136
const response = UrlFetchApp.fetch(
125137
`https://api.github.com/repos/${repo.owner}/${repo.name}/actions/workflows/update-calendar.yml/dispatches`,
126138
options);
139+
const status = response.getResponseCode();
127140
if (status !== 200 && status !== 204) {
128141
reportError(`I could not start the job that refreshes the W3C calendar.
129142
@@ -157,9 +170,22 @@ export default async function () {
157170
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Schedule published');
158171
}
159172
else {
173+
const calendar = (
174+
project.metadata.calendar && project.metadata.calendar !== 'no'
175+
) ? `<p>
176+
I triggered an update of the W3C calendar to propagate possible changes
177+
that I may have missed such as updates to session descriptions.
178+
</p>
179+
<p>
180+
Please allow a few minutes for the W3C calendar to get updated,
181+
and up to an hour for the schedule to reach the event's page on
182+
w3.org (if it exists).
183+
</p>` : '';
160184
const htmlOutput = HtmlService
161185
.createHtmlOutput(`
162-
<p>Data seems up-to-date already, nothing to export!</p>`
186+
<p>The schedule itself was already up-to-date,
187+
sessions did not need to be updated.</p>` +
188+
calendar
163189
)
164190
.setWidth(400)
165191
.setHeight(400);

0 commit comments

Comments
 (0)