<commit_before>package net.perfectdreams.loritta.utils

import com.mongodb.client.model.Filters
import com.mrpowergamerbr.loritta.userdata.MongoServerConfig
import com.mrpowergamerbr.loritta.utils.loritta
import com.mrpowergamerbr.loritta.utils.lorittaShards
import net.dv8tion.jda.api.entities.Guild

object PurgeDiscordGuilds {
	/**
	 * Get guilds that can be purged due to bot inactivity
	 *
	 * @param lastCommandReceivedBefore how many ms should have been passed for a guild to be considered "inactive"
	 *
	 * @return a list containing all matched guilds with their server configs
	 */
	fun getGuildsToBePurged(lastCommandReceivedBefore: Long): List<GuildAndServerConfig> {
		val stuff = loritta.serversColl.find(
				Filters.lte("lastCommandReceivedAt", lastCommandReceivedBefore)
		).toMutableList().filter {
			!it.joinLeaveConfig.isEnabled &&
					it.youTubeConfig.channels.isEmpty() &&
					it.livestreamConfig.channels.isEmpty() &&
					!it.starboardConfig.isEnabled &&
					!it.eventLogConfig.isEnabled &&
					!it.autoroleConfig.isEnabled &&
					!it.inviteBlockerConfig.isEnabled
		}

		return stuff.mapNotNull {
			val guild = lorittaShards.getGuildById(it.guildId)

			if (guild != null)
				GuildAndServerConfig(guild, it)
			else null
		}
	}

	data class GuildAndServerConfig(
			val guild: Guild,
			val serverConfig: MongoServerConfig
	)
}<commit_msg>Verificar se o tempo que ela entrou é superior ao tempo que utilizaram comandos<commit_after>package net.perfectdreams.loritta.utils

import com.mongodb.client.model.Filters
import com.mrpowergamerbr.loritta.userdata.MongoServerConfig
import com.mrpowergamerbr.loritta.utils.loritta
import com.mrpowergamerbr.loritta.utils.lorittaShards
import net.dv8tion.jda.api.entities.Guild

object PurgeDiscordGuilds {
	/**
	 * Get guilds that can be purged due to bot inactivity
	 *
	 * @param lastCommandReceivedBefore how many ms should have been passed for a guild to be considered "inactive"
	 *
	 * @return a list containing all matched guilds with their server configs
	 */
	fun getGuildsToBePurged(lastCommandReceivedBefore: Long): List<GuildAndServerConfig> {
		val stuff = loritta.serversColl.find(
				Filters.lte("lastCommandReceivedAt", lastCommandReceivedBefore)
		).toMutableList().filter {
			!it.joinLeaveConfig.isEnabled &&
					it.youTubeConfig.channels.isEmpty() &&
					it.livestreamConfig.channels.isEmpty() &&
					!it.starboardConfig.isEnabled &&
					!it.eventLogConfig.isEnabled &&
					!it.autoroleConfig.isEnabled &&
					!it.inviteBlockerConfig.isEnabled
		}

		return stuff.mapNotNull {
			val guild = lorittaShards.getGuildById(it.guildId)

			if (guild != null)
				GuildAndServerConfig(guild, it)
			else null
		}.filter {
			// Verificar se ela entrou a mais do que a última vez que executaram comandos, as vezes "0" pode significar "eu acabei de entrar e nunca usaram comandos meus!"
			lastCommandReceivedBefore > it.guild.selfMember.timeJoined.toInstant().toEpochMilli()
		}
	}

	data class GuildAndServerConfig(
			val guild: Guild,
			val serverConfig: MongoServerConfig
	)
}
{'fraction_non_alphanumeric': 0.08813008130081301, 'fraction_numerical': 0.000975609756097561, 'mean_word_length': 4.434628975265018, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '2408123', 'n_tokens_mistral': 1115, 'n_tokens_neox': 982, 'n_words': 222}