<commit_before>package org.xwiki.android.sync.ViewModel

import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.xwiki.android.sync.allUsersCacheRepository
import org.xwiki.android.sync.bean.ObjectSummary
import org.xwiki.android.sync.bean.XWikiGroup
import org.xwiki.android.sync.contactdb.UserAccount
import org.xwiki.android.sync.contactdb.UserAccountId
import org.xwiki.android.sync.groupsCacheRepository
import org.xwiki.android.sync.userAccountsRepo

class SyncSettingsViewModel(
    application: Application,
    private var id: UserAccountId
) : AndroidViewModel(application) {
    suspend fun getUser() : UserAccount? {
        return userAccountsRepo.findByAccountId(id)
    }

    fun updateUser(updatedUserAccount: UserAccount) {
        viewModelScope.launch(Dispatchers.Default) {
            userAccountsRepo.updateAccount(updatedUserAccount)
        }
    }

    fun updateAllUsersCache(summaries: List<ObjectSummary>, userID: UserAccountId) {
        viewModelScope.launch(Dispatchers.Default) {
            allUsersCacheRepository[userID] = summaries
        }
    }

    fun getAllUsersCache(userID: UserAccountId): List<ObjectSummary>? {
        return allUsersCacheRepository[userID]<commit_msg>SyncSettingsViewModel#id now is constant<commit_after>package org.xwiki.android.sync.ViewModel

import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.xwiki.android.sync.allUsersCacheRepository
import org.xwiki.android.sync.bean.ObjectSummary
import org.xwiki.android.sync.bean.XWikiGroup
import org.xwiki.android.sync.contactdb.UserAccount
import org.xwiki.android.sync.contactdb.UserAccountId
import org.xwiki.android.sync.groupsCacheRepository
import org.xwiki.android.sync.userAccountsRepo

class SyncSettingsViewModel(
    application: Application,
    private val id: UserAccountId
) : AndroidViewModel(application) {
    suspend fun getUser() : UserAccount? {
        return userAccountsRepo.findByAccountId(id)
    }

    fun updateUser(updatedUserAccount: UserAccount) {
        viewModelScope.launch(Dispatchers.Default) {
            userAccountsRepo.updateAccount(updatedUserAccount)
        }
    }

    fun updateAllUsersCache(summaries: List<ObjectSummary>, userID: UserAccountId) {
        viewModelScope.launch(Dispatchers.Default) {
            allUsersCacheRepository[userID] = summaries
        }
    }

    fun getAllUsersCache(userID: UserAccountId): List<ObjectSummary>? {
        return allUsersCacheRepository[userID]
{'fraction_non_alphanumeric': 0.07824887969665632, 'fraction_numerical': 0.0, 'mean_word_length': 4.804, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6722744', 'n_tokens_mistral': 834, 'n_tokens_neox': 824, 'n_words': 130}