<commit_before>//
//  SearchedMangaCollectionViewModel.swift
//  Yomu
//
//  Created by <NAME> on 7/29/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import RxCocoa
import RxMoya
import RxMoya_ModelMapper
import RxSwift
import Swiftz

struct SearchedMangaCollectionViewModel {
  // MARK: Public
  var disposeBag = DisposeBag()

  // MARK: Output
  var count: Int {
    return _mangas.value.count
  }
  let reload: Driver<Void>
  let showViewController: Driver<Bool>
  let fetching: Driver<Bool>

  // MARK: Private
  fileprivate let _fetching = Variable(false)
  fileprivate let _showViewController = Variable(false)
  fileprivate let _mangas = Variable(List<SearchedMangaViewModel>())

  init() {
    reload = _mangas
      .asDriver()
      .map(void)

    fetching = _fetching.asDriver()
    showViewController = _fetching.asDriver()
  }

  subscript(index: Int) -> SearchedMangaViewModel {
    return _mangas.value[UInt(index)]
  }

  func search(term: String) -> Disposable {
    let api = YomuAPI.search(term)
    let request = Yomu.request(api)

    let fetchingDisposable = request
      .map(const(false))
      .asDriver(onErrorJustReturn: false)
      .startWith(true)
      .drive(_fetching)

    let resultDisposable = request
      .filterSuccessfulStatusCodes()
      .mapArray(SearchedManga.self, withRootKey: "mangas")
      .asDriver(onErrorJustReturn: [])
      .map {
        $0.map(SearchedMangaViewModel.init)
      }
      .map(List<SearchedMangaViewModel>.init)
      .drive(_mangas)

    return CompositeDisposable(fetchingDisposable, resultDisposable)
  }

  func hideViewController() {
    _showViewController.value = false
  }
}
<commit_msg>Remove unused import<commit_after>//
//  SearchedMangaCollectionViewModel.swift
//  Yomu
//
//  Created by <NAME> on 7/29/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import RxCocoa
import RxMoya
import RxSwift
import Swiftz

struct SearchedMangaCollectionViewModel {
  // MARK: Public
  var disposeBag = DisposeBag()

  // MARK: Output
  var count: Int {
    return _mangas.value.count
  }
  let reload: Driver<Void>
  let showViewController: Driver<Bool>
  let fetching: Driver<Bool>

  // MARK: Private
  fileprivate let _fetching = Variable(false)
  fileprivate let _showViewController = Variable(false)
  fileprivate let _mangas = Variable(List<SearchedMangaViewModel>())

  init() {
    reload = _mangas
      .asDriver()
      .map(void)

    fetching = _fetching.asDriver()
    showViewController = _fetching.asDriver()
  }

  subscript(index: Int) -> SearchedMangaViewModel {
    return _mangas.value[UInt(index)]
  }

  func search(term: String) -> Disposable {
    let api = YomuAPI.search(term)
    let request = Yomu.request(api)

    let fetchingDisposable = request
      .map(const(false))
      .asDriver(onErrorJustReturn: false)
      .startWith(true)
      .drive(_fetching)

    let resultDisposable = request
      .filterSuccessfulStatusCodes()
      .mapArray(SearchedManga.self, withRootKey: "mangas")
      .asDriver(onErrorJustReturn: [])
      .map {
        $0.map(SearchedMangaViewModel.init)
      }
      .map(List<SearchedMangaViewModel>.init)
      .drive(_mangas)

    return CompositeDisposable(fetchingDisposable, resultDisposable)
  }

  func hideViewController() {
    _showViewController.value = false
  }
}

{'fraction_non_alphanumeric': 0.10475905417539659, 'fraction_numerical': 0.00598623166716552, 'mean_word_length': 3.2901155327342746, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '6742784', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1078, 'n_words': 226}