<commit_before>import RSS from '../models/rss';
import Podcast from '../models/podcast';

import config from '../config';
import packageInfo from '../../../app/package.json';

import Redis from 'ioredis';
const cache = new Redis(config.cache.uri);

exports.list = async (req, res) => {
	const cacheKey = `featured:v${packageInfo.version.replace(/\./g, ':')}`;

	let str = await cache.get(cacheKey);
	let data = JSON.parse(str);

	if (!data) {
		const rss = await RSS.find({ featured: true });
		data = [];
		rss.map(feed => {
			feed.type = 'rss';
			data.push(feed);
		});

		const podcasts = await Podcast.find({ featured: true });
		podcasts.map(podcast => {
			podcast.type = 'podcast';
			data.push(podcast);
		});

		await cache.set(cacheKey, JSON.stringify(data), 'EX', 60 * 30);
	}

	let shuffled = data
		.map(a => [Math.random(), a])
		.sort((a, b) => a[0] - b[0])
		.map(a => a[1]);

	res.json(shuffled);
};<commit_msg>Returning proper type key and value.<commit_after>import RSS from '../models/rss';
import Podcast from '../models/podcast';

import config from '../config';
import packageInfo from '../../../app/package.json';

import Redis from 'ioredis';
const cache = new Redis(config.cache.uri);

exports.list = async (req, res) => {
	const cacheKey = `featured:v${packageInfo.version.replace(/\./g, ':')}`;

	let str = await cache.get(cacheKey);
	let data = JSON.parse(str);

	if (!data) {
		data = [];

		const rss = await RSS.find({ featured: true });
		rss.map(doc => {
			let r = doc.toObject();
			r.type = 'rss';
			data.push(r);
		});

		const podcasts = await Podcast.find({ featured: true });
		podcasts.map(doc => {
			let p = doc.toObject();
			p.type = 'podcast';
			data.push(p);
		});

		await cache.set(cacheKey, JSON.stringify(data), 'EX', 60 * 30);
	}

	let shuffled = data
		.map(a => [Math.random(), a])
		.sort((a, b) => a[0] - b[0])
		.map(a => a[1]);

	res.json(shuffled);
};
{'fraction_non_alphanumeric': 0.20939947780678853, 'fraction_numerical': 0.007310704960835509, 'mean_word_length': 3.334841628959276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '5425890', 'n_tokens_mistral': 757, 'n_tokens_neox': 693, 'n_words': 171}