<commit_before>package com.androidmess.helix.discovery.presentation

import com.androidmess.helix.common.model.data.MovieResult
import com.androidmess.helix.common.presentation.base.BaseMvpPresenter
import com.androidmess.helix.common.rx.SchedulersInjector
import com.androidmess.helix.discovery.model.data.DiscoverMovieViewModel
import com.androidmess.helix.discovery.usecase.GetDiscoveryMoviesUseCase
import com.androidmess.helix.discovery.view.DiscoverView
import io.reactivex.Observable
import io.reactivex.disposables.CompositeDisposable

class DiscoveryPresenter(schedulersInjector: SchedulersInjector,
                         val getDiscoveryMoviesUseCase: GetDiscoveryMoviesUseCase)
    : BaseMvpPresenter<DiscoverView>(schedulersInjector) {

    // FIXME add loading next pages
    var page: Int = 1
    var disposables: CompositeDisposable = CompositeDisposable()

    override fun connect(view: DiscoverView) {
        super.connect(view)
        val discoverDisposable = getDiscoveryMoviesUseCase
                .execute(page)
                .observeOn(schedulersInjector.ui())
                .doOnSubscribe { view.showLoading(true) }
                .doFinally { view.showLoading(false) }
                .flatMapIterable(MovieResult::results)
                .flatMap { Observable.just(DiscoverMovieViewModel.Mapper.fromMovie(it)) }
                .toList()
                .subscribeOn(schedulersInjector.io())
                .subscribe({ view.showMovies(it) },<commit_msg>Workaround for Jacoco and Kotlin constructor with val issue<commit_after>package com.androidmess.helix.discovery.presentation

import com.androidmess.helix.common.model.data.MovieResult
import com.androidmess.helix.common.presentation.base.BaseMvpPresenter
import com.androidmess.helix.common.rx.SchedulersInjector
import com.androidmess.helix.discovery.model.data.DiscoverMovieViewModel
import com.androidmess.helix.discovery.usecase.GetDiscoveryMoviesUseCase
import com.androidmess.helix.discovery.view.DiscoverView
import io.reactivex.Observable
import io.reactivex.disposables.CompositeDisposable

class DiscoveryPresenter(schedulersInjector: SchedulersInjector,
                         getDiscoveryMoviesUseCase: GetDiscoveryMoviesUseCase)
    : BaseMvpPresenter<DiscoverView>(schedulersInjector) {

    // FIXME Find a way to move it to constructor and exclude from coverage reports
    val getDiscoveryMoviesUseCase: GetDiscoveryMoviesUseCase = getDiscoveryMoviesUseCase

    // FIXME add loading next pages
    var page: Int = 1
    var disposables: CompositeDisposable = CompositeDisposable()

    override fun connect(view: DiscoverView) {
        super.connect(view)
        val discoverDisposable = getDiscoveryMoviesUseCase
                .execute(page)
                .observeOn(schedulersInjector.ui())
                .doOnSubscribe { view.showLoading(true) }
                .doFinally { view.showLoading(false) }
                .flatMapIterable(MovieResult::results)
                .flatMap { Observable.just(DiscoverMovieViewModel.Mapper.fromMovie(it)) }
                .toList()
                .subscribeOn(schedulersInjector.io())
                .subscribe({ view.showMovies(it) },
{'fraction_non_alphanumeric': 0.07927590511860175, 'fraction_numerical': 0.0006242197253433209, 'mean_word_length': 3.420689655172414, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2019896', 'n_tokens_mistral': 968, 'n_tokens_neox': 884, 'n_words': 143}