Skip to content

Commit

Permalink
feat(backend): published property in event table.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Sep 28, 2023
1 parent ecfc942 commit c2b9fec
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class EventDao(
private val projectName: String,
private val database: BasicDatabase
) {
suspend fun list(): List<EventDb> = database.getAll(projectName)
suspend fun list(): List<EventDb> = database
.getAll<EventDb>(projectName)
.filter { it.published }
suspend fun get(id: String): EventDb? = database.get(projectName, id)
suspend fun getVerified(id: String, apiKey: String?): EventDb {
val eventDb = database.get<EventDb>(projectName, id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ data class EventDb(
val linkedinUrl: String? = null,
val faqLink: String? = null,
val codeOfConductLink: String? = null,
val published: Boolean = false,
val updatedAt: Long = System.currentTimeMillis(),
val agendaUpdatedAt: Long = System.currentTimeMillis()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ fun EventInput.convertToDb(event: EventDb, addressDb: AddressDb) = EventDb(
linkedinUrl = this.linkedinUrl,
faqLink = this.faqLink,
codeOfConductLink = this.codeOfConductLink,
published = published,
updatedAt = this.updatedAt
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ class EventRepository(
val now = LocalDateTime.now()
return EventList(
future = events
.filter { LocalDateTime.parse(it.startDate.dropLast(1)).isAfter(now) }
.filter { LocalDateTime.parse(it.endDate.dropLast(1)).isAfter(now) }
.sortedBy { it.startDate },
past = events
.filter { LocalDateTime.parse(it.startDate.dropLast(1)).isBefore(now) }
.sortedBy { it.startDate }
.sortedBy { it.endDate }
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ data class EventInput(
val linkedinUrl: String?,
@SerialName("faq_link")
val faqLink: String,
val published: Boolean,
@SerialName("code_of_conduct_link")
val codeOfConductLink: String,
@SerialName("update_at")
Expand Down

0 comments on commit c2b9fec

Please sign in to comment.