Skip to content

Commit

Permalink
Introduce additional field imageUrl (#1101)
Browse files Browse the repository at this point in the history
Co-authored-by: Ashley Davies <[email protected]>
  • Loading branch information
ashdavies and ashdavies authored Aug 6, 2024
1 parent d8fc437 commit 1049ecb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
24 changes: 6 additions & 18 deletions cloud-run/src/commonMain/kotlin/io/ashdavies/cloud/Events.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,14 @@ internal fun Route.events() {
}
}

@Suppress("UNCHECKED_CAST")
internal fun Map<String, Any?>.encode(prefix: String): Map<String, Any?> = buildMap {
this@encode.forEach { entry ->
when (entry.key.startsWith(prefix) && entry.value != null) {
false -> put(entry.key, entry.value)
true -> {
val value = getOrElse(prefix) { mutableMapOf<String, Any?>() } as Map<String, Any?>
val key = entry.key.drop(prefix.length).replaceFirstChar { it.lowercase() }
put(prefix, value + (key to entry.value))
}
}
}
}

private fun AsgEvent.toEvent(id: String): Event = Event(
id = id, name = name, website = website, location = location, dateStart = dateStart,
dateEnd = dateEnd, status = status, online = online,
cfp = cfp?.let { cfp -> EventCfp(start = cfp.start, end = cfp.end, site = cfp.site) },
private fun AsgEvent.toEvent(id: String) = Event(
id = id, name = name, website = website, location = location, imageUrl = imageUrl,
dateStart = dateStart, dateEnd = dateEnd, status = status, online = online,
cfp = cfp?.toEventCfp(),
)

private fun AsgEvent.Cfp.toEventCfp() = EventCfp(start = start, end = end, site = site)

private fun todayAsString(): String = Clock.System
.todayIn(TimeZone.currentSystemDefault())
.toString()
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public data class AsgEvent(
@SerialName("name") public val name: String,
@SerialName("website") public val website: String,
@SerialName("location") public val location: String,
@SerialName("imageUrl") public val imageUrl: String? = null,
@SerialName("online") public val online: Boolean? = false,
@SerialName("status") public val status: String? = null,
@SerialName("date_start") public val dateStart: String,
Expand Down
2 changes: 2 additions & 0 deletions openapi-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ definitions:
type: "string"
location:
type: "string"
imageUrl:
type: "string"
status:
type: "string"
online:
Expand Down

0 comments on commit 1049ecb

Please sign in to comment.