Commit 12033718 authored by Konstantin Tskhovrebov's avatar Konstantin Tskhovrebov 🤖

fixed "null" text and events ordering

parent 50bb8b9c
......@@ -10,7 +10,7 @@ data class TargetHeader(
val author: Author,
val icon: TargetHeaderIcon,
val title: TargetHeaderTitle,
val body: CharSequence?,
val body: CharSequence,
val date: LocalDateTime,
val target: AppTarget,
val targetId: Long,
......
......@@ -104,6 +104,7 @@ interface GitlabApi {
@Query("before") beforeDay: String?,
@Query("after") afterDay: String?,
@Query("sort") sort: Sort?,
@Query("order_by") orderBy: OrderBy?,
@Query("page") page: Int,
@Query("per_page") pageSize: Int
): Single<List<Event>>
......
......@@ -4,6 +4,7 @@ import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.functions.BiFunction
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.OrderBy
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.PushDataRefType
import ru.terrakok.gitlabclient.entity.Sort
......@@ -16,7 +17,6 @@ import ru.terrakok.gitlabclient.model.data.server.GitlabApi
import ru.terrakok.gitlabclient.model.system.SchedulersProvider
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.DefaultPageSize
import java.text.SimpleDateFormat
import javax.inject.Inject
/**
......@@ -28,23 +28,24 @@ class EventRepository @Inject constructor(
@DefaultPageSize private val defaultPageSizeWrapper: PrimitiveWrapper<Int>
) {
private val defaultPageSize = defaultPageSizeWrapper.value
private val dayFormat = SimpleDateFormat("yyyy-MM-dd")
fun getEvents(
action: EventAction? = null,
targetType: EventTarget? = null,
beforeDay: LocalDateTime? = null,
afterDay: LocalDateTime? = null,
sort: Sort? = null,
sort: Sort? = Sort.DESC,
orderBy: OrderBy = OrderBy.UPDATED_AT,
page: Int,
pageSize: Int = defaultPageSize
): Single<List<TargetHeader>> = api
.getEvents(
action,
targetType,
beforeDay?.run { dayFormat.format(this) },
afterDay?.run { dayFormat.format(this) },
beforeDay?.run { this.toLocalDate().toString() },
afterDay?.run { this.toLocalDate().toString() },
sort,
orderBy,
page,
pageSize
)
......@@ -85,7 +86,7 @@ class EventRepository @Inject constructor(
targetData.name,
project?.name ?: ""
),
getBody(event),
getBody(event) ?: "",
event.createdAt,
targetData.target,
targetData.id,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment