export async function sendPotentialInteractives()

in packages/repocop/src/remediation/topics/topic-monitor-interactive.ts [16:50]


export async function sendPotentialInteractives(
	evaluatedRepos: repocop_github_repository_rules[],
	config: Config,
) {
	const potentialInteractives: string[] = shuffle(
		findPotentialInteractives(evaluatedRepos),
	)
		.map((repo) => removeRepoOwner(repo))
		.filter((repo) => repo !== '');

	const snsBatchMaximum = Math.min(
		potentialInteractives.length,
		config.interactivesCount,
	);

	const somePotentialInteractives = potentialInteractives.slice(
		0,
		snsBatchMaximum,
	);

	console.log(
		`Found ${potentialInteractives.length} potential interactives of ${evaluatedRepos.length} evaluated repositories`,
	);

	const publishRequestEntry = new PublishCommand({
		Message: JSON.stringify(somePotentialInteractives),
		TopicArn: config.interactiveMonitorSnsTopic,
	});

	const strList = somePotentialInteractives.join(', ');
	console.log(
		`Sending ${snsBatchMaximum} potential interactives to SNS. ${strList}`,
	);
	await new SNSClient(awsClientConfig(config.stage)).send(publishRequestEntry);
}