<commit_before>package com.cagnosolutions.starter.app.user

import groovy.transform.CompileStatic
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.domain.Page
import org.springframework.data.domain.PageRequest
import org.springframework.data.domain.Sort
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import org.springframework.stereotype.Repository
import org.springframework.stereotype.Service

/**
 * Created by <NAME>.
 * Copyright Cagno Solutions. All rights reserved.
 */

@CompileStatic
@Service(value = "userService")
class UserService {

    @Autowired
    UserRepository repo

    List<User> findAll() {
        repo.findAll()
    }

    Page<User> findAll(int page, int size, String... fields) {
        repo.findAll(new PageRequest(page, size, Sort.Direction.ASC, fields))
    }

    boolean canUpdate(Long id, String username) {
        (repo.canUpdate((id == null) ? 0 : id, username) == 0)
    }

    User findOne(Long id) {
        repo.findOne id
    }

    User findOne(String username) {
        repo.findOne username
    }

    User save(User user) {
        if(user.id == null)
            user.creation = System.currentTimeMillis()
        repo.save user
    }

    def delete(Long id) {
        repo.delete id
    }<commit_msg>Update UserData.groovy<commit_after>package com.cagnosolutions.starter.app.user

import groovy.transform.CompileStatic
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.domain.Page
import org.springframework.data.domain.PageRequest
import org.springframework.data.domain.Sort
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import org.springframework.stereotype.Repository
import org.springframework.stereotype.Service

/**
 * Created by <NAME>.
 * Copyright Cagno Solutions. All rights reserved.
 */

@CompileStatic
@Service(value = "userService")
class UserService {

    @Autowired
    UserRepository repo

    List<User> findAll() {
        repo.findAll()
    }

    Page<User> findAll(int page, int size, String... fields) {
        repo.findAll(new PageRequest(page, size, Sort.Direction.ASC, fields))
    }

    boolean canUpdate(Long id, String username) {
        (repo.canUpdate((id == null) ? 0L : id, username) == 0)
    }

    User findOne(Long id) {
        repo.findOne id
    }

    User findOne(String username) {
        repo.findOne username
    }

    User save(User user) {
        if(user.id == null)
            user.creation = System.currentTimeMillis()
        repo.save user
    }

    def delete(Long id) {
        repo.delete id
    }
{'fraction_non_alphanumeric': 0.10372714486638537, 'fraction_numerical': 0.0014064697609001407, 'mean_word_length': 3.265367316341829, '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': '5217890', 'n_tokens_mistral': 834, 'n_tokens_neox': 811, 'n_words': 179}