<commit_before>package com.jamieadkins.gwent.data.update.repository

import android.util.Log
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.jamieadkins.gwent.data.BuildConfig
import com.jamieadkins.gwent.data.CardsApi
import com.jamieadkins.gwent.data.Constants
import com.jamieadkins.gwent.data.StoreManager
import com.jamieadkins.gwent.data.update.model.FirebaseNotice
import com.jamieadkins.gwent.domain.update.model.Notice
import com.jamieadkins.gwent.domain.update.repository.NoticesRepository
import com.nytimes.android.external.store3.base.impl.BarCode
import io.reactivex.Observable
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import javax.inject.Inject

class NoticesRepositoryImpl @Inject constructor(private val storeManager: StoreManager) : NoticesRepository {

    val gson = Gson()
    private val cardsApi = Retrofit.Builder()
        .baseUrl(Constants.CARDS_API_BASE_URL)
        .addConverterFactory(GsonConverterFactory.create(gson))
        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
        .validateEagerly(BuildConfig.DEBUG)
        .build()
        .create(CardsApi::class.java)

    override fun getNotices(): Observable<List<Notice>> {
        val barcode = BarCode(Constants.CACHE_KEY, StoreManager.generateId("notices"))
        return storeManager.getDataOnce<List<FirebaseNotice>>(barcode, cardsApi.fetchNotices("en"), genericType<List<FirebaseNotice>>(), 10)
            .map {
                it.map { notice ->
                    Notice(
                        notice.id,
                        notice.title,
                        notice.body,
                        notice.enabled
                    )
                }
            }
            .toObservable()
    }

    inline fun <reified T> genericType() = object : TypeToken<T>() {}.type
}<commit_msg>Added notices<commit_after>package com.jamieadkins.gwent.data.update.repository

import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.jamieadkins.gwent.data.BuildConfig
import com.jamieadkins.gwent.data.CardsApi
import com.jamieadkins.gwent.data.Constants
import com.jamieadkins.gwent.data.StoreManager
import com.jamieadkins.gwent.data.update.model.FirebaseNotice
import com.jamieadkins.gwent.domain.update.model.Notice
import com.jamieadkins.gwent.domain.update.repository.NoticesRepository
import com.nytimes.android.external.store3.base.impl.BarCode
import io.reactivex.Observable
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import javax.inject.Inject

class NoticesRepositoryImpl @Inject constructor(private val storeManager: StoreManager) : NoticesRepository {

    val gson = Gson()
    private val cardsApi = Retrofit.Builder()
        .baseUrl(Constants.CARDS_API_BASE_URL)
        .addConverterFactory(GsonConverterFactory.create(gson))
        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
        .validateEagerly(BuildConfig.DEBUG)
        .build()
        .create(CardsApi::class.java)

    override fun getNotices(): Observable<List<Notice>> {
        val barcode = BarCode(Constants.CACHE_KEY, StoreManager.generateId("notices"))
        return storeManager.getDataOnce<List<FirebaseNotice>>(barcode, cardsApi.fetchNotices("en"), genericType<List<FirebaseNotice>>(), 10)
            .map {
                it.map { notice ->
                    Notice(
                        notice.id,
                        notice.title,
                        notice.body,
                        notice.enabled
                    )
                }
            }
            .onErrorReturnItem(emptyList())
            .toObservable()
    }

    inline fun <reified T> genericType() = object : TypeToken<T>() {}.type
}
{'fraction_non_alphanumeric': 0.0955920041004613, 'fraction_numerical': 0.0046130189646335215, 'mean_word_length': 2.98265306122449, 'pattern_counts': {'":': 0, '<': 19, '<?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': '3145248', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1114, 'n_words': 170}