<commit_before>package backend.model.user

import backend.model.challenges.Challenge
import backend.model.challenges.ChallengeRepository
import backend.model.event.TeamRepository
import backend.model.event.Team
import backend.model.posting.Posting
import backend.model.sponsoring.Sponsoring
import backend.model.location.Location
import backend.model.location.LocationRepository
import backend.model.media.MediaRepository
import backend.model.messaging.GroupMessage
import backend.model.messaging.GroupMessageRepository
import backend.model.misc.Email
import backend.model.misc.EmailRepository
import backend.model.payment.*
import backend.model.posting.PostingRepository
import backend.model.sponsoring.SponsoringRepository
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
class DeletionServiceImpl @Autowired constructor(private val userRepository: UserRepository,
                                                 private val postingRepository: PostingRepository,
                                                 private val mediaRepository: MediaRepository,
                                                 private val locationRepository: LocationRepository,
                                                 private val sponsoringRepository: SponsoringRepository,
                                                 private val sponsoringInvoiceRepository: SponsoringInvoiceRepository,
                                                 private val teamRepository: TeamRepository,
                                                 private val messageRepository: GroupMessageRepository,
                                                 private val challengeRepository: ChallengeRepository,
                                                 private val emailRepository: EmailRepository) : DeletionService {

    fun delete(email: Email) {
        emailRepository.delete(email)
    }

 override   fun delete(team: Team) {
        teamRepository.delete(team)
    }

    fun anonymize(invoice: SponsoringInvoice) {
        invoice.removeSponsor()
        sponsoringInvoiceRepository.save(invoice)
    }

    fun anonymize(location: Location) {
        location.uploader = null
        locationRepository.save(location)
    }

    fun anonymize(groupMessage: GroupMessage, user: User) {
        groupMessage.messages
                .filter { it.creator?.id == user.account.id }
                .forEach {
                    it.text = ""
                    it.creator = null
                }

        groupMessage.users.removeIf { it.account.id == user.account.id }
        messageRepository.save(groupMessage)<commit_msg>delete-team-profile | formattin<commit_after>package backend.model.user

import backend.model.challenges.Challenge
import backend.model.challenges.ChallengeRepository
import backend.model.event.TeamRepository
import backend.model.event.Team
import backend.model.posting.Posting
import backend.model.sponsoring.Sponsoring
import backend.model.location.Location
import backend.model.location.LocationRepository
import backend.model.media.MediaRepository
import backend.model.messaging.GroupMessage
import backend.model.messaging.GroupMessageRepository
import backend.model.misc.Email
import backend.model.misc.EmailRepository
import backend.model.payment.*
import backend.model.posting.PostingRepository
import backend.model.sponsoring.SponsoringRepository
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
class DeletionServiceImpl @Autowired constructor(private val userRepository: UserRepository,
                                                 private val postingRepository: PostingRepository,
                                                 private val mediaRepository: MediaRepository,
                                                 private val locationRepository: LocationRepository,
                                                 private val sponsoringRepository: SponsoringRepository,
                                                 private val sponsoringInvoiceRepository: SponsoringInvoiceRepository,
                                                 private val teamRepository: TeamRepository,
                                                 private val messageRepository: GroupMessageRepository,
                                                 private val challengeRepository: ChallengeRepository,
                                                 private val emailRepository: EmailRepository) : DeletionService {

    fun delete(email: Email) {
        emailRepository.delete(email)
    }

    override fun delete(team: Team) {
        teamRepository.delete(team)
    }

    fun anonymize(invoice: SponsoringInvoice) {
        invoice.removeSponsor()
        sponsoringInvoiceRepository.save(invoice)
    }

    fun anonymize(location: Location) {
        location.uploader = null
        locationRepository.save(location)
    }

    fun anonymize(groupMessage: GroupMessage, user: User) {
        groupMessage.messages
                .filter { it.creator?.id == user.account.id }
                .forEach {
                    it.text = ""
                    it.creator = null
                }

        groupMessage.users.removeIf { it.account.id == user.account.id }
        messageRepository.save(groupMessage)
{'fraction_non_alphanumeric': 0.061106074342701724, 'fraction_numerical': 0.0, 'mean_word_length': 2.152, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4936236', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1117, 'n_words': 244}