Skip to content

Commit

Permalink
event sync
Browse files Browse the repository at this point in the history
  • Loading branch information
wslyvh committed Oct 29, 2024
1 parent d73ad6f commit 174f542
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
20 changes: 19 additions & 1 deletion devcon-api/data/events/devcon-7.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@
"venue_address": "60 Ratchadaphisek Rd, Khlong Toei, Bangkok 10110, Thailand",
"venue_website": "https://www.qsncc.com/",
"venue_directions": "https://maps.app.goo.gl/XLGaN7B9zViAe3DB6",
"rooms": [],
"rooms": [
"music-stage",
"classroom-a",
"classroom-b",
"classroom-c",
"classroom-d",
"classroom-e",
"breakout-1",
"breakout-2",
"breakout-3",
"stage-1",
"stage-2",
"stage-3",
"stage-4",
"stage-5",
"stage-6",
"main-stage",
"keynote"
],
"version": "0"
}
1 change: 1 addition & 0 deletions devcon-api/src/clients/pretalx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export async function GetLastcheduleUpdate() {
return lastUpdate.valueOf()
} catch (e) {
console.log('Unable to fetch schedule update. Make sure the event name is correct and made public.')
return 0
}
}

Expand Down
12 changes: 11 additions & 1 deletion devcon-api/src/scripts/sync-pretalx.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GetData } from '@/clients/filesystem'
import { GetRooms, GetSessions, GetSpeakers } from '@/clients/pretalx'
import { GetLastcheduleUpdate, GetRooms, GetSessions, GetSpeakers } from '@/clients/pretalx'
import { CreatePresentationFromTemplate } from '@/clients/slides'
import fs from 'fs'

Expand Down Expand Up @@ -31,6 +31,15 @@ async function syncRooms() {
fs.writeFileSync(`./data/rooms/devcon-7/${room.id}.json`, JSON.stringify(room, null, 2))
}

// Update event data
const event = GetData('events').find((e: any) => e.id === 'devcon-7')
delete event.id
const eventVersion = await GetLastcheduleUpdate()
fs.writeFileSync(
`./data/events/devcon-7.json`,
JSON.stringify({ ...event, rooms: rooms.map((r: any) => r.id), version: eventVersion.toString() }, null, 2)
)

console.log('Synced Pretalx Rooms')
console.log('')
}
Expand Down Expand Up @@ -101,6 +110,7 @@ async function createPresentations() {
main()
.then(async () => {
console.log('All done!')
process.exit(0)
})
.catch(async (e) => {
console.error(e)
Expand Down

0 comments on commit 174f542

Please sign in to comment.