<commit_before>package com.nilhcem.droidcontn.data.database.dao;

import com.nilhcem.droidcontn.data.database.DbMapper;
import com.nilhcem.droidcontn.data.database.model.SelectedSession;
import com.nilhcem.droidcontn.data.database.model.Session;
import com.nilhcem.droidcontn.utils.Preconditions;
import com.squareup.sqlbrite.BriteDatabase;

import java.util.List;
import java.util.Locale;

import javax.inject.Inject;
import javax.inject.Singleton;

import rx.Observable;

@Singleton
public class SessionsDao {

    private final BriteDatabase database;
    private final DbMapper dbMapper;
    private final SpeakersDao speakersDao;

    @Inject
    public SessionsDao(BriteDatabase database, DbMapper dbMapper, SpeakersDao speakersDao) {
        this.database = database;
        this.dbMapper = dbMapper;
        this.speakersDao = speakersDao;
    }

    public Observable<List<com.nilhcem.droidcontn.data.app.model.Session>> getSessions() {
        Preconditions.checkNotOnMainThread();

        return Observable.zip(
                database.createQuery(Session.TABLE, "SELECT * FROM " + Session.TABLE)
                        .mapToList(Session.MAPPER).first(),
                speakersDao.getSpeakersMap(),
                dbMapper::toAppSessions);
    }

    public void saveSessions(List<com.nilhcem.droidcontn.data.app.model.Session> toSave) {
        BriteDatabase.Transaction transaction = database.newTransaction();<commit_msg>Ensure saveSessions call is not done on the main thread<commit_after>package com.nilhcem.droidcontn.data.database.dao;

import com.nilhcem.droidcontn.data.database.DbMapper;
import com.nilhcem.droidcontn.data.database.model.SelectedSession;
import com.nilhcem.droidcontn.data.database.model.Session;
import com.nilhcem.droidcontn.utils.Preconditions;
import com.squareup.sqlbrite.BriteDatabase;

import java.util.List;
import java.util.Locale;

import javax.inject.Inject;
import javax.inject.Singleton;

import rx.Observable;

@Singleton
public class SessionsDao {

    private final BriteDatabase database;
    private final DbMapper dbMapper;
    private final SpeakersDao speakersDao;

    @Inject
    public SessionsDao(BriteDatabase database, DbMapper dbMapper, SpeakersDao speakersDao) {
        this.database = database;
        this.dbMapper = dbMapper;
        this.speakersDao = speakersDao;
    }

    public Observable<List<com.nilhcem.droidcontn.data.app.model.Session>> getSessions() {
        return Observable.zip(
                database.createQuery(Session.TABLE, "SELECT * FROM " + Session.TABLE)
                        .mapToList(Session.MAPPER).first(),
                speakersDao.getSpeakersMap(),
                dbMapper::toAppSessions);
    }

    public void saveSessions(List<com.nilhcem.droidcontn.data.app.model.Session> toSave) {
        Preconditions.checkNotOnMainThread();

        BriteDatabase.Transaction transaction = database.newTransaction();
{'fraction_non_alphanumeric': 0.09289617486338798, 'fraction_numerical': 0.0, 'mean_word_length': 3.590909090909091, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6101135', 'n_tokens_mistral': 889, 'n_tokens_neox': 889, 'n_words': 152}