Skip to content

Commit

Permalink
fix: added log for exisitng meetings
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleytodd committed Mar 2, 2024
1 parent 82949a0 commit 7cf82bc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
schedules: 2020-04-02T17:00:00.0Z/P1D
issueTitle: 'Test Meeting <%= date.toFormat("yyyy-MM-dd") %>'
createWithin: P2D
meetingLabels: testMeeting, test
meetingLabels: test
agendaLabel: meeting-agenda-test
createNotes: true
repos: pkgjs/meet,pkgjs/meet
Expand Down
1 change: 1 addition & 0 deletions lib/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports.update = async function (client, issue) {
}

module.exports.getMeetingIssues = async function (client, opts) {
console.log(`Checking for meeting issues ${opts.owner}/${opts.repo}#${opts.meetingLabels}`)
const resp = await client.paginate('GET /repos/{owner}/{repo}/issues', {
owner: opts.owner,
repo: opts.repo,
Expand Down
16 changes: 10 additions & 6 deletions lib/meetings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ module.exports.createNextMeeting = async function (client, opts) {
}

module.exports.setMeetingIssueBody = async function (client, opts) {
const issue = await getNextIssue(client, opts)
const issue = getNextIssue(opts)
issue.body = typeof opts.template === 'function' ? opts.template(issue) : opts.template
return issues.update(client, issue)
}

async function getNextIssue (client, opts) {
function getNextIssue (opts) {
const now = opts.now || DateTime.utc()
const date = getNextScheduledMeeting(opts.schedules, now)
const title = typeof opts.issueTitle === 'function' ? opts.issueTitle({ date }) : opts.issueTitle
Expand All @@ -40,7 +40,7 @@ async function getNextIssue (client, opts) {
const shouldCreateNextMeetingIssue = module.exports.shouldCreateNextMeetingIssue = async function (client, opts = {}) {
const now = opts.now || DateTime.utc()
const createWithin = Duration.fromISO(opts.createWithin)
const issue = getNextIssue(client, opts)
const issue = getNextIssue(opts)
const { date: next, title: nextIssueTitle } = issue

// Further out than the create within limit
Expand All @@ -51,15 +51,19 @@ const shouldCreateNextMeetingIssue = module.exports.shouldCreateNextMeetingIssue
const meetings = await issues.getMeetingIssues(client, {
owner: opts.owner,
repo: opts.repo,
label: opts.meetingLabels
meetingLabels: opts.meetingLabels
})

const shouldCreate = !meetings.find((i) => {
console.log(`Checking for meeting titled ${nextIssueTitle}`)
const shouldCreate = meetings.find((i) => {
console.log(`Found meeting issue ${i.title}`)
return i.title === nextIssueTitle
})
if (!shouldCreate) {
if (shouldCreate) {
console.log(`Found existing meeting issue: #${shouldCreate.number}`)
return false
}
console.log('No existing meeting issues found')

// Load issues for agenda
return issue
Expand Down
2 changes: 1 addition & 1 deletion run.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const conversions = require('./lib/conversions')
const createWithin = core.getInput('createWithin')

// variables we use for labels
const meetingLabels = core.getInput('meetingLabels')
const agendaLabel = core.getInput('agendaLabel')
const meetingLabels = core.getInput('meetingLabels')

// variables we use for content
const issueTitle = core.getInput('issueTitle')
Expand Down

0 comments on commit 7cf82bc

Please sign in to comment.