import redis from './redis.js';

export async function getIdsBySlug(slugs, domain) {
	const ids = await Promise.all(slugs.map(async (slug) => {
		if (!slug) {
			return null;
		}

		if (Number(slug)) {
			return Number(slug); // already an ID or missing
		}

		const id = await redis.hGet(`traxxx:${domain}:id_by_slug`, slug);

		return Number(id);
	}));

	return ids.filter(Boolean);
}
