Skip to content

Commit

Permalink
fix(backend): better implementation for third party OpenPlanner.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Apr 2, 2024
1 parent d35928e commit 152be9d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ class EventRepository(
openPlanner.event.formats
.map { async { formatDao.createOrUpdate(eventId, it.convertToDb()) } }
.awaitAll()
val allSpeakers = openPlanner.sessions
.map { it.speakerIds }.flatten()
openPlanner.speakers
.filter { allSpeakers.contains(it.id) }
.map { async { speakerDao.createOrUpdate(eventId, it.convertToDb()) } }
.awaitAll()
openPlanner.sessions
Expand All @@ -176,7 +179,7 @@ class EventRepository(
it.value.forEachIndexed { index, sessionOP ->
scheduleItemDao.createOrUpdate(
eventId,
sessionOP.convertToScheduleDb(index)
sessionOP.convertToScheduleDb(index, openPlanner.event.tracks)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fun Route.registerEventRoutes(
}
post("/events/{eventId}/openplanner") {
val eventId = call.parameters["eventId"]!!
val apiKey = call.parameters["api_key"] ?: throw NotAuthorized
val apiKey = call.request.queryParameters["api_key"] ?: throw NotAuthorized
call.respond(HttpStatusCode.Created, repository.openPlanner(eventId, apiKey))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ fun SessionOP.convertToTalkDb() = TalkDb(
linkReplay = null
)

fun SessionOP.convertToScheduleDb(order: Int) = ScheduleDb(
fun SessionOP.convertToScheduleDb(order: Int, tracks: List<TrackOP>) = ScheduleDb(
order = order,
startTime = dateStart?.split("+")?.first()
?: error("Can't schedule a talk without a start time"),
endTime = dateEnd?.split("+")?.first()
?: error("Can't schedule a talk without a end time"),
room = trackId ?: error("Can't schedule a talk without a room"),
room = trackId?.let { tracks.find { it.id == trackId }?.name }
?: error("Can't schedule a talk without a room"),
talkId = id
)

0 comments on commit 152be9d

Please sign in to comment.