Skip to content

Commit

Permalink
chore: update ktlint
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Apr 7, 2024
1 parent 5f04017 commit 5daee05
Show file tree
Hide file tree
Showing 118 changed files with 527 additions and 378 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class MainActivity : ComponentActivity() {
enableEdgeToEdge(
statusBarStyle = SystemBarStyle.auto(
android.graphics.Color.TRANSPARENT,
android.graphics.Color.TRANSPARENT,
android.graphics.Color.TRANSPARENT
) { inDarkTheme },
navigationBarStyle = SystemBarStyle.auto(lightScrim, darkScrim) { inDarkTheme },
navigationBarStyle = SystemBarStyle.auto(lightScrim, darkScrim) { inDarkTheme }
)
onDispose {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ class CategoryDao(private val database: Database) {
)

suspend fun createOrUpdate(eventId: String, item: CategoryDb) {
if (item.id == null) database.insert(
eventId = eventId,
collectionName = CollectionName
) { item.copy(id = it) }
else database.update(
eventId = eventId,
collectionName = CollectionName,
id = item.id,
item = item
)
if (item.id == null) {
database.insert(
eventId = eventId,
collectionName = CollectionName
) { item.copy(id = it) }
} else {
database.update(
eventId = eventId,
collectionName = CollectionName,
id = item.id,
item = item
)
}
}

suspend fun deleteDiff(eventId: String, ids: List<String>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ class EventDao(

suspend fun createOrUpdate(event: EventDb) {
val existing = database.get<EventDb>(projectName, event.slugId)
if (existing == null) database.insert(projectName, event.slugId, event)
else database.update(
projectName,
event.slugId,
event.copy(updatedAt = System.currentTimeMillis())
)
if (existing == null) {
database.insert(projectName, event.slugId, event)
} else {
database.update(
projectName,
event.slugId,
event.copy(updatedAt = System.currentTimeMillis())
)
}
}

suspend fun updateMenus(eventId: String, apiKey: String, menus: List<LunchMenuDb>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ data class OpenPlannerConfigurationDb(
data class BilletWebConfigurationDb(
val eventId: String = "",
val userId: String = "",
val apiKey: String = "",
val apiKey: String = ""
)

data class WldConfigurationDb(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ class EventRepository(
async {
val scheduleItems = it.value.map {
async {
if (it.talkId == null) it.convertToModel(null)
else {
if (it.talkId == null) {
it.convertToModel(null)
} else {
val talk = talkDao.get(eventDb.slugId, it.talkId)
?: return@async it.convertToModel(null)
it.convertToModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ class EventRepositoryV2(
formats: List<FormatDb>,
eventDb: EventDb
) = async {
if (schedule.talkId == null) schedule.convertToModel(null)
else {
if (schedule.talkId == null) {
schedule.convertToModel(null)
} else {
val talk = talks.find { it.id == schedule.talkId }
?: return@async schedule.convertToModel(null)
val speakersTalk = speakers.filter { talk.speakerIds.contains(it.id) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ class FormatDao(private val database: Database) {
)

suspend fun createOrUpdate(eventId: String, item: FormatDb) {
if (item.id == null) database.insert(
eventId = eventId,
collectionName = CollectionName
) { item.copy(id = it) }
else database.update(
eventId = eventId,
collectionName = CollectionName,
id = item.id,
item = item
)
if (item.id == null) {
database.insert(
eventId = eventId,
collectionName = CollectionName
) { item.copy(id = it) }
} else {
database.update(
eventId = eventId,
collectionName = CollectionName,
id = item.id,
item = item
)
}
}

suspend fun deleteDiff(eventId: String, ids: List<String>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ interface BasicDatabase {
suspend fun count(collectionName: String): Long
suspend fun <T : Any> get(collectionName: String, id: String, clazz: KClass<T>): T?
suspend fun <T : Any> getAll(collectionName: String, clazz: KClass<T>): List<T>
suspend fun <T : Any> query(collectionName: String, clazz: KClass<T>, vararg ops: WhereOperation):
List<Pair<String, T>>
suspend fun <T : Any> query(
collectionName: String,
clazz: KClass<T>,
vararg ops: WhereOperation
): List<Pair<String, T>>

suspend fun <T : Any> insert(collectionName: String, eventId: String, item: T)
suspend fun <T : Any> update(collectionName: String, eventId: String, item: T)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ interface Storage {

object Factory {
fun create(storage: CloudStorage, bucketName: String, isAppEngine: Boolean): Storage {
return if (isAppEngine) BucketStorage(storage, bucketName)
else LocalStorage(bucketName)
return if (isAppEngine) {
BucketStorage(storage, bucketName)
} else {
LocalStorage(bucketName)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ class JobRepository(
val jobsDb = jobs.hits
.filter { it.title.contains("spontaneous_application").not() }
.map { hit ->
val id = if (hit.companyId.length < MaxPartnerChar) hit.companyId
else "${hit.companyId.substring(0..MaxPartnerChar)}-${hit.publishDate}"
val id = if (hit.companyId.length < MaxPartnerChar) {
hit.companyId
} else {
"${hit.companyId.substring(0..MaxPartnerChar)}-${hit.publishDate}"
}
val partnerId = partners.find { it.wldId == hit.companyId }?.id
?: throw NotAcceptableException("Partner WLD ${hit.companyId} not found")
hit.convertToDb(id, partnerId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,28 @@ class PartnerDao(private val database: Database, private val storage: Storage) {
}

suspend fun createOrUpdate(eventId: String, partner: PartnerDb): String = coroutineScope {
if (partner.id == "") return@coroutineScope database.insert(
eventId = eventId,
collectionName = CollectionName
) { partner.copy(id = it) }
if (partner.id == "") {
return@coroutineScope database.insert(
eventId = eventId,
collectionName = CollectionName
) { partner.copy(id = it) }
}
val existing = database.get<PartnerDb>(eventId = eventId, collectionName = CollectionName, id = partner.id)
if (existing == null) database.insert(
eventId = eventId, collectionName = CollectionName,
id = partner.id,
item = partner
)
else database.update(
eventId = eventId,
collectionName = CollectionName,
id = partner.id,
item = partner
)
if (existing == null) {
database.insert(
eventId = eventId,
collectionName = CollectionName,
id = partner.id,
item = partner
)
} else {
database.update(
eventId = eventId,
collectionName = CollectionName,
id = partner.id,
item = partner
)
}
return@coroutineScope partner.id
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ class QAndADao(private val database: Database) {
)

suspend fun createOrUpdate(eventId: String, item: QAndADb) {
if (item.id == null) database.insert(
eventId = eventId,
collectionName = CollectionName
) { item.copy(id = it) }
else database.update(
eventId = eventId,
collectionName = CollectionName,
id = item.id,
item = item
)
if (item.id == null) {
database.insert(
eventId = eventId,
collectionName = CollectionName
) { item.copy(id = it) }
} else {
database.update(
eventId = eventId,
collectionName = CollectionName,
id = item.id,
item = item
)
}
}

suspend fun hasQAndA(eventId: String): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ class ScheduleItemDao(private val database: Database) {

suspend fun createOrUpdate(eventId: String, item: ScheduleDb) {
val existing = database.get<ScheduleDb>(eventId = eventId, collectionName = CollectionName, id = item.id)
if (existing == null) database.insert(
eventId = eventId,
collectionName = CollectionName,
id = item.id,
item = item
)
else database.update(eventId = eventId, collectionName = CollectionName, id = item.id, item = item)
if (existing == null) {
database.insert(
eventId = eventId,
collectionName = CollectionName,
id = item.id,
item = item
)
} else {
database.update(eventId = eventId, collectionName = CollectionName, id = item.id, item = item)
}
}

suspend fun delete(eventId: String, id: String) = database.delete(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class ScheduleRepository(
val category = categoryDao.get(eventId, talkDb.category)
val format = formatDao.get(eventId, talkDb.format)
talkDb.convertToModel(speakers, category, format, eventDb)
} else null
} else {
null
}
return@coroutineScope scheduleItem.convertToModel(talk)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,28 @@ class SpeakerDao(private val database: Database, private val storage: Storage) {
}

suspend fun createOrUpdate(eventId: String, speaker: SpeakerDb): String = coroutineScope {
if (speaker.id == "") return@coroutineScope database.insert(
eventId = eventId,
collectionName = CollectionName
) { speaker.copy(id = it) }
if (speaker.id == "") {
return@coroutineScope database.insert(
eventId = eventId,
collectionName = CollectionName
) { speaker.copy(id = it) }
}
val existing = database.get<SpeakerDb>(eventId = eventId, collectionName = CollectionName, id = speaker.id)
if (existing == null) database.insert(
eventId = eventId,
collectionName = CollectionName,
id = speaker.id,
item = speaker
)
else database.update(
eventId = eventId,
collectionName = CollectionName,
id = speaker.id,
item = speaker
)
if (existing == null) {
database.insert(
eventId = eventId,
collectionName = CollectionName,
id = speaker.id,
item = speaker
)
} else {
database.update(
eventId = eventId,
collectionName = CollectionName,
id = speaker.id,
item = speaker
)
}
return@coroutineScope speaker.id
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ fun org.gdglille.devfest.backend.third.parties.conferencehall.Speaker.convertToD
bio = this.bio ?: "",
company = this.company,
photoUrl = url,
twitter = if (this.twitter == null) null
else if (this.twitter.contains("twitter.com")) this.twitter
else "https://twitter.com/${this.twitter}",
github = if (this.github == null) null
else if (this.github.contains("github.com")) this.github
else "https://github.com/${this.github}",
twitter = if (this.twitter == null) {
null
} else if (this.twitter.contains("twitter.com")) {
this.twitter
} else {
"https://twitter.com/${this.twitter}"
},
github = if (this.github == null) {
null
} else if (this.github.contains("github.com")) {
this.github
} else {
"https://github.com/${this.github}"
},
linkedin = null
)

Expand Down
27 changes: 16 additions & 11 deletions backend/src/main/java/org/gdglille/devfest/backend/talks/TalkDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,23 @@ class TalkDao(private val database: Database) {
}

suspend fun createOrUpdate(eventId: String, talk: TalkDb): String = coroutineScope {
if (talk.id == "") return@coroutineScope database.insert(
eventId = eventId,
collectionName = CollectionName
) { talk.copy(id = it) }
if (talk.id == "") {
return@coroutineScope database.insert(
eventId = eventId,
collectionName = CollectionName
) { talk.copy(id = it) }
}
val existing = database.get<TalkDb>(eventId = eventId, collectionName = CollectionName, id = talk.id)
if (existing == null) database.insert(
eventId = eventId,
collectionName = CollectionName,
id = talk.id,
item = talk
)
else database.update(eventId = eventId, collectionName = CollectionName, id = talk.id, item = talk)
if (existing == null) {
database.insert(
eventId = eventId,
collectionName = CollectionName,
id = talk.id,
item = talk
)
} else {
database.update(eventId = eventId, collectionName = CollectionName, id = talk.id, item = talk)
}
return@coroutineScope talk.id
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ fun Talk.convertToDb(): TalkDb = TalkDb(
category = this.categories,
format = this.formats,
language = this.language,
speakerIds = this.speakers,
speakerIds = this.speakers
)
Loading

0 comments on commit 5daee05

Please sign in to comment.