<commit_before>import Ember from 'ember';

function filterShows(shows) {
	return shows.filter(function(show) {
		return Ember.get(show, 'showThumbnails.length') > 0 && Ember.get(show, 'cgExempt') === false;
	}).slice(0, 16);
}

export default Ember.Route.extend({
	recentPrograms: null,
	galleryName: 'Latest videos',
	model: function() {
		var self = this;
		var channel = this.modelFor('application');
		var galleryName = 'Recent Programs';

		return channel.get('publicSite').
			then(function(site) {
				return Ember.RSVP.hash({
					logo: site.get('logo'),
					carouselSavedSearch: site.get('carouselSavedSearch'),
					gallerySavedSearch: site.get('gallerySavedSearch')
				});
			}).
			then(function(searches) {
				var galleryPrograms, carouselPrograms, logo;
				logo = searches.logo;
				if (!searches.carouselSavedSearch) {
					carouselPrograms = self.store.find('show', {pageSize: 50});
				} else {
					carouselPrograms = self.store.findByIds('show', searches.carouselSavedSearch.get('results').slice(0, 50));
				}
				if (!searches.gallerySavedSearch) {
					galleryPrograms = self.store.find('show', {pageSize: 50});
				} else {
					galleryName = searches.gallerySavedSearch.get('name');
					galleryPrograms = self.store.findByIds('show', searches.gallerySavedSearch.get('results').slice(0, 50));
				}

				return Ember.RSVP.hash({
					logo: logo,
					channel: channel,
					schedule: channel.get('schedule'),
					galleryName: galleryName,
					carouselPrograms: carouselPrograms.then(filterShows),
					galleryPrograms: galleryPrograms.then(filterShows)
				});
			}).
			catch(function() {
				// If there is an error just return some defaults
				return Ember.RSVP.hash({
					logo: null,
					channel: channel,
					galleryName: 'Recent Programs',
					carouselPrograms: self.store.find('show', {pageSize: 50}).then(filterShows),
					galleryPrograms: self.store.find('show', {pageSize: 50}).then(filterShows)
				});
			});
	},
	actions: {<commit_msg>bugzid: 10125 - Provide location filter to api to exclude cleared shows<commit_after>import Ember from 'ember';

function filterShows(shows) {
	return shows.filter(function(show) {
		return Ember.get(show, 'showThumbnails.length') > 0 && Ember.get(show, 'cgExempt') === false;
	}).slice(0, 16);
}

export default Ember.Route.extend({
	recentPrograms: null,
	galleryName: 'Latest videos',
	model: function() {
		var self = this;
		var channel = this.modelFor('application');
		var galleryName = 'Recent Programs';
    var defaultQuery = {pageSize: 50, location: channel.get('primaryLocation')};

		return channel.get('publicSite').
			then(function(site) {
				return Ember.RSVP.hash({
					logo: site.get('logo'),
					carouselSavedSearch: site.get('carouselSavedSearch'),
					gallerySavedSearch: site.get('gallerySavedSearch')
				});
			}).
			then(function(searches) {
				var galleryPrograms, carouselPrograms, logo;
				logo = searches.logo;
				if (!searches.carouselSavedSearch) {
					carouselPrograms = self.store.find('show', defaultQuery);
				} else {
					carouselPrograms = self.store.findByIds('show', searches.carouselSavedSearch.get('results').slice(0, 50));
				}
				if (!searches.gallerySavedSearch) {
					galleryPrograms = self.store.find('show', defaultQuery);
				} else {
					galleryName = searches.gallerySavedSearch.get('name');
					galleryPrograms = self.store.findByIds('show', searches.gallerySavedSearch.get('results').slice(0, 50));
				}

				return Ember.RSVP.hash({
					logo: logo,
					channel: channel,
					schedule: channel.get('schedule'),
					galleryName: galleryName,
					carouselPrograms: carouselPrograms.then(filterShows),
					galleryPrograms: galleryPrograms.then(filterShows)
				});
			}).
			catch(function() {
				// If there is an error just return some defaults
				return Ember.RSVP.hash({
					logo: null,
					channel: channel,
					galleryName: 'Recent Programs',
					carouselPrograms: self.store.find('show', defaultQuery).then(filterShows),
					galleryPrograms: self.store.find('show', defaultQuery).then(filterShows)
				});
			});
	},
	actions: {
{'fraction_non_alphanumeric': 0.1439375457428641, 'fraction_numerical': 0.008538667967797023, 'mean_word_length': 3.9817739975698663, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1413681', 'n_tokens_mistral': 1645, 'n_tokens_neox': 1293, 'n_words': 254}