Skip to content

Commit

Permalink
fix: location
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickHeneise committed Sep 5, 2024
1 parent 8e1333c commit 13569bc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 20 deletions.
24 changes: 14 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98948,19 +98948,23 @@ var __webpack_exports__ = {}
}
}

if (locations && locations.length > 0) {
const locationLookup = locations.find((l) => l.id === location.id)
if (!locationLookup) {
event.location = location.text
} else {
event.location = locationLookup.name
if (locationLookup.geo) {
const [lat, lon] = locationLookup.geo
event.geo = { lat, lon }
if (location) {
if (locations && locations.length > 0) {
const locationLookup = locations.find((l) => l.id === location.id)
if (!locationLookup) {
event.location = location.text
} else {
event.location = locationLookup.name
if (locationLookup.geo) {
const [lat, lon] = locationLookup.geo
event.geo = { lat, lon }
}
}
} else {
event.location = location.text ? location.text : ''
}
} else {
event.location = location.text ? location.text : ''
event.location = ''
}

events.push(event)
Expand Down
17 changes: 17 additions & 0 deletions e2e/realworld.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import github from '@actions/github'
import { createIcs } from '../src/create-ics.js'
import { fetchIssues } from '../src/fetch-issues.js'

async function run() {
const repoToken = process.env.GH_TOKEN
const locationsFile = 'locations.json'
const timeZone = 'America/Denver'

const octokit = github.getOctokit(repoToken)

const events = await fetchIssues(octokit, locationsFile, timeZone)

await createIcs(events)
}

run()
24 changes: 14 additions & 10 deletions src/fetch-issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,23 @@ export async function fetchIssues(
}
}

if (locations && locations.length > 0) {
const locationLookup = locations.find((l) => l.id === location.id)
if (!locationLookup) {
event.location = location.text
} else {
event.location = locationLookup.name
if (locationLookup.geo) {
const [lat, lon] = locationLookup.geo
event.geo = { lat, lon }
if (location) {
if (locations && locations.length > 0) {
const locationLookup = locations.find((l) => l.id === location.id)
if (!locationLookup) {
event.location = location.text
} else {
event.location = locationLookup.name
if (locationLookup.geo) {
const [lat, lon] = locationLookup.geo
event.geo = { lat, lon }
}
}
} else {
event.location = location.text ? location.text : ''
}
} else {
event.location = location.text ? location.text : ''
event.location = ''
}

events.push(event)
Expand Down

0 comments on commit 13569bc

Please sign in to comment.