<commit_before>package org.stepik.android.remote.last_step

import io.reactivex.Maybe
import org.stepic.droid.web.Api
import org.stepik.android.data.last_step.source.LastStepRemoteDataSource
import org.stepik.android.domain.last_step.model.LastStep
import javax.inject.Inject

class LastStepRemoteDataSourceImpl
@Inject
constructor(
   private val api: Api
) : LastStepRemoteDataSource {
    override fun getLastStep(id: String): Maybe<LastStep> =
        Maybe.create { emitter ->
            api.getLastStepResponse(id)
                .execute()
                .body()
                ?.lastSteps
                ?.firstOrNull()
                ?.let {
                    it.unit ?: return@let null
                    it.lesson ?: return@let null
                    it.step ?: return@let null
                    LastStep(id = it.id, unit = it.unit, lesson = it.lesson, step = it.step)
                }
                ?.let(emitter::onSuccess)
                ?: emitter.onComplete()
        }
}<commit_msg>use safe Maybe constructor in last step remote repository<commit_after>package org.stepik.android.remote.last_step

import io.reactivex.Maybe
import org.stepic.droid.web.Api
import org.stepik.android.data.last_step.source.LastStepRemoteDataSource
import org.stepik.android.domain.last_step.model.LastStep
import javax.inject.Inject

class LastStepRemoteDataSourceImpl
@Inject
constructor(
   private val api: Api
) : LastStepRemoteDataSource {
    override fun getLastStep(id: String): Maybe<LastStep> =
        Maybe.fromCallable {
            api.getLastStepResponse(id)
                .execute()
                .body()
                ?.lastSteps
                ?.firstOrNull()
                ?.let {
                    it.unit ?: return@let null
                    it.lesson ?: return@let null
                    it.step ?: return@let null
                    LastStep(id = it.id, unit = it.unit, lesson = it.lesson, step = it.step)
                }
        }
}
{'fraction_non_alphanumeric': 0.09502262443438914, 'fraction_numerical': 0.0, 'mean_word_length': 1.9221732745961821, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3440581', 'n_tokens_mistral': 574, 'n_tokens_neox': 543, 'n_words': 111}