Skip to content

Commit

Permalink
feat: close issues to cancel an event
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickHeneise committed Apr 28, 2022
1 parent fcaf1d0 commit 846b1a2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
9 changes: 8 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68211,6 +68211,7 @@ var __webpack_exports__ = {}
edges {
node {
id
state
url
title
body
Expand Down Expand Up @@ -68287,8 +68288,8 @@ var __webpack_exports__ = {}
description: content.text,
url: issue.url,
categories: issue.labels.nodes.map((l) => l.name),
status: 'CONFIRMED',
busyStatus: 'BUSY',
status: 'CONFIRMED',
organizer: { name: organizer },
attendees: issue.reactions.edges.map((r) => {
return {
Expand All @@ -68303,6 +68304,12 @@ var __webpack_exports__ = {}
})
}

if (fetch_issues_zonedTimeToUtc(zonedDateTime) > new Date()) {
if (issue.state === 'CLOSED') {
event.status = 'CANCELLED'
}
}

if (locations && locations.length > 0) {
const locationLookup = locations.find((l) => l.id === location.id)
if (!locationLookup) {
Expand Down
9 changes: 8 additions & 1 deletion src/fetch-issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export async function fetchIssues(
edges {
node {
id
state
url
title
body
Expand Down Expand Up @@ -106,8 +107,8 @@ export async function fetchIssues(
description: content.text,
url: issue.url,
categories: issue.labels.nodes.map((l) => l.name),
status: 'CONFIRMED',
busyStatus: 'BUSY',
status: 'CONFIRMED',
organizer: { name: organizer },
attendees: issue.reactions.edges.map((r) => {
return {
Expand All @@ -122,6 +123,12 @@ export async function fetchIssues(
})
}

if (zonedTimeToUtc(zonedDateTime) > new Date()) {
if (issue.state === 'CLOSED') {
event.status = 'CANCELLED'
}
}

if (locations && locations.length > 0) {
const locationLookup = locations.find((l) => l.id === location.id)
if (!locationLookup) {
Expand Down
7 changes: 4 additions & 3 deletions test/fetch-issues.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const response = {
id: 'I_kwDOG7tNxM5E9yP8',
url: 'https://github.com/gitevents/ics-test/issues/1',
title: 'testing events',
body: "### Event Description\n\nLet's meet for coffee and chat about tech, coding, Cyprus and the newly formed CDC (Cyprus Developer Community).\n\n### Location\n\n[Caffe Nero Finikoudes, Larnaka](https://goo.gl/maps/Bzjxdeat3BSdsUSVA)\n\n### Date\n\n11.03.2022\n\n### Time\n\n16:00\n\n### Duration\n\n2h\n\n### Code of Conduct\n\n- [X] I agree to follow this project's [Code of Conduct](https://berlincodeofconduct.org)",
state: 'CLOSED',
body: "### Event Description\n\nLet's meet for coffee and chat about tech, coding, Cyprus and the newly formed CDC (Cyprus Developer Community).\n\n### Location\n\n[Caffe Nero Finikoudes, Larnaka](https://goo.gl/maps/Bzjxdeat3BSdsUSVA)\n\n### Date\n\n11.12.2022\n\n### Time\n\n16:00\n\n### Duration\n\n2h\n\n### Code of Conduct\n\n- [X] I agree to follow this project's [Code of Conduct](https://berlincodeofconduct.org)",
createdAt: '2022-03-02T11:13:46Z',
updatedAt: '2022-03-02T11:14:04Z',
labels: {
Expand Down Expand Up @@ -74,6 +75,6 @@ test('fetchIssues() returns parsed issues/events', async (t) => {
t.ok(value)

const lines = value.split(/\n/g)
t.deepEqual(actual[0].start, [2022, 3, 11, 14, 0])
t.equal(lines[10].replace(/[\n\r]/g, ''), 'DTSTART:20220311T140000Z')
t.deepEqual(actual[0].start, [2022, 12, 11, 14, 0])
t.equal(lines[10].replace(/[\n\r]/g, ''), 'DTSTART:20221211T140000Z')
})

0 comments on commit 846b1a2

Please sign in to comment.