Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to assign notetakers to meeting issues #54

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions scripts/assign-note-takers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env node
/* eslint-disable max-len */
const IssueUpdater = require('./modules/IssueUpdater');

const NUM_ISSUES = 20;

// let's go!
(async function() {
const issueUpdater = new IssueUpdater(NUM_ISSUES);

// create new Github issues
const issuedUpdated = await issueUpdater.updateNotetakers();
console.log(`Updated ${issuedUpdated} new issues!`);

})();
59 changes: 57 additions & 2 deletions scripts/modules/IssueUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const ISSUE_TEMPLATE_BODY = `This is wg-outreach's regular weekly meeting with v
**Instructions for joining the meeting**
Please join us on Google Meet with [this link](https://meet.google.com/hvn-ihfs-tnz).

**Notetaker**
(Not assigned yet)

**Agenda**
*Note: Add a comment on this issue to propose items for the agenda.*

Expand Down Expand Up @@ -55,9 +58,9 @@ class IssueUpdater {
}

/**
* @return {Date} latestIssueDate
* @return {Array} issues
*/
async getLatestIssueDate() {
async fetchIssues() {
const result = await this._repo.issuesAsync({
per_page: 100,
state: 'open',
Expand All @@ -73,6 +76,14 @@ class IssueUpdater {
});

this._issues.sort((a, b) => b.dateObj.getTime() - a.dateObj.getTime() );
return this._issues;
}

/**
* @return {Object} latestIssue
*/
async getLatestIssueDate() {
await this.fetchIssues();
return this._issues[0];
}

Expand Down Expand Up @@ -100,6 +111,50 @@ class IssueUpdater {

return totalNewIssues;
}

/**
* @return {Number} totalnewIssues
*/
async updateNotetakers() {
// find out what the latest generated meeting item was
const issues = await this.fetchIssues();
let updated = 0;
const notetakers = [
'sebastianbenz',
'alankent',
'CrystalOnScript',
'mattludwig',
'morsssss',
'mrjoro',
'pbakaus',
];

for (let index = 0; index < issues.length; index++) {
const issue = issues[index];
if (/\(Not assigned yet\)/.test(issue.body)) {
await this._repo.client.patchAsync('/repos/' + this._repo.name + '/issues/' + issue.number, {
'body': issue.body.replace('(Not assigned yet)', '@' + notetakers[index % notetakers.length]),
});
updated++;
}
}

/*
return this.client.patch("/repos/" + this.repo + "/issues/" + this.number, obj, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Issue update error"));
} else {
return cb(null, b, h);
}
});
*/

return updated;
}

/**
* @param {String} dateString
* @return {Array} issue
Expand Down
Loading