Skip to content

Commit

Permalink
Merge pull request #1237 from joreilly/floor-plan-and-language
Browse files Browse the repository at this point in the history
AM2024: Add floor plan and language
  • Loading branch information
martinbonnin authored Apr 4, 2024
2 parents 1e7dde2 + 23c1114 commit 57c2b89
Showing 1 changed file with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import dev.johnoreilly.confetti.backend.datastore.DVenue
import dev.johnoreilly.confetti.backend.datastore.DataStore
import kotlinx.datetime.LocalDate
import kotlinx.datetime.LocalDateTime
import net.mbonnin.bare.graphql.asBoolean
import net.mbonnin.bare.graphql.asList
import net.mbonnin.bare.graphql.asMap
import net.mbonnin.bare.graphql.asString
Expand Down Expand Up @@ -54,7 +55,7 @@ object Sessionize {
latitude = 48.8188958,
longitude = 2.3193016,
imageUrl = "https://www.beffroidemontrouge.com/wp-content/uploads/2019/09/moebius-1.jpg",
floorPlanUrl = null
floorPlanUrl = "https://storage.googleapis.com/androidmakers-static/floor_plan.png"
),
partnerGroups = listOf(
DPartnerGroup(
Expand Down Expand Up @@ -621,6 +622,9 @@ object Sessionize {
)
}

/**
* @param gridSmartUrl extra json to get the service sessions from. The service sessions are not always in the View/All url
*/
private suspend fun getData(
url: String,
gridSmartUrl: String? = null,
Expand All @@ -638,10 +642,9 @@ object Sessionize {
}.toMap()


val sessions = if (gridSmartUrl != null) {
getSessions(gridSmartUrl, categories, linksFor)
} else {
getSessions(data!!, categories, linksFor)
var sessions = getSessions(data!!, categories, linksFor)
if (gridSmartUrl != null) {
sessions = sessions + getServiceSessions(gridSmartUrl, categories, linksFor)
}

var rooms = data.asMap["rooms"].asList.map { it.asMap }.map {
Expand Down Expand Up @@ -679,7 +682,7 @@ object Sessionize {
)
}

private suspend fun getSessions(
private suspend fun getServiceSessions(
gridSmart: String,
categories: Map<Any?, Any?>,
linksFor: suspend (String) -> List<DLink>
Expand All @@ -692,25 +695,30 @@ object Sessionize {
it.asMap
}
.mapNotNull {
if ((it.get("isServiceSession") as? Boolean) != true) {
// Filter service sessions
return@mapNotNull null
}
if (it.get("startsAt") == null || it.get("endsAt") == null) {
/**
* Guard against sessions that are not scheduled.
*/
return@mapNotNull null
}
val tags = it.get("categoryItems")?.asList.orEmpty().mapNotNull { categoryId ->
categories.get(categoryId)?.asString
}
DSession(
id = it.get("id").asString,
type = if (it.get("isServiceSession").cast()) "service" else "talk",
title = it.get("title").asString,
description = it.get("description")?.asString,
language = "en-US",
language = tags.toLanguage(),
start = it.get("startsAt").asString.let { LocalDateTime.parse(it) },
end = it.get("endsAt").asString.let { LocalDateTime.parse(it) },
complexity = null,
feedbackId = null,
tags = it.get("categoryItems")?.asList.orEmpty().mapNotNull { categoryId ->
categories.get(categoryId)?.asString
},
tags = tags,
rooms = listOf(it.get("roomId").toString()),
speakers = it.get("speakers")?.asList.orEmpty().map { it.asMap["id"].asString },
shortDescription = null,
Expand All @@ -734,19 +742,20 @@ object Sessionize {
*/
return@mapNotNull null
}
val tags = it.get("categoryItems").asList.mapNotNull { categoryId ->
categories.get(categoryId)?.asString
}
DSession(
id = it.get("id").asString,
type = if (it.get("isServiceSession").cast()) "service" else "talk",
title = it.get("title").asString,
description = it.get("description")?.asString,
language = "en-US",
language = tags.toLanguage(),
start = it.get("startsAt").asString.let { LocalDateTime.parse(it) },
end = it.get("endsAt").asString.let { LocalDateTime.parse(it) },
complexity = null,
feedbackId = null,
tags = it.get("categoryItems").asList.mapNotNull { categoryId ->
categories.get(categoryId)?.asString
},
tags = tags,
rooms = listOf(it.get("roomId").toString()),
speakers = it.get("speakers").asList.map { it.asString },
shortDescription = null,
Expand All @@ -755,3 +764,7 @@ object Sessionize {
}
}
}

private fun List<String>.toLanguage(): String {
return if(contains("French")) "French" else "English"
}

0 comments on commit 57c2b89

Please sign in to comment.