<commit_before>'use strict';

angular.module("mopify.discover.featured", [
    "mopify.services.mopidy",
    "mopify.services.spotifylogin",
    "spotify",
    "mopify.services.util",
    "mopify.services.station",
    'mopify.widgets.directive.album'
])

.config(function($routeProvider) {
    $routeProvider.when("/discover/featured", {
        templateUrl: "discover/featured/featured.tmpl.html",
        controller: "DiscoverFeaturedController"
    });
})


.controller("DiscoverFeaturedController", function DiscoverFeaturedController($rootScope, $scope, $timeout, mopidyservice, Spotify, SpotifyLogin, util, stationservice){

    $scope.featuredplaylists = [];
    $scope.titletext = "Loading...";
    $scope.headerplaylist = {};

    // Load the feautured playlists when a connection with mopidy has been established
    $scope.$on("mopidy:state:online", loadFeaturedPlaylists);
    if(mopidyservice.isConnected)
        loadFeaturedPlaylists();

    /**
     * Load all the data for the featured playlists page
     */
    function loadFeaturedPlaylists(){
        // Check if we are logged in to spotify 
        if(SpotifyLogin.connected){
            // Get the featured playlists from spotify
            // TODO: Change the locale to a setting value
            Spotify.getFeaturedPlaylists({
                locale: "nl_NL",
                country: "NL",
                limit: 12
            }).then(function(data){
                // Set the message and items
                $scope.titletext = data.message;
                $scope.featuredplaylists = data.playlists.items;
                $scope.headerplaylist = data.playlists.items[Math.floor(Math.random() * 10)];

                // Load the tracks for the featured header playlist
                loadHeaderPlaylistTracks();
            });
        }
        else{
            $scope.titletext = "Please connect to Spotify";
        }
    }

    function loadHeaderPlaylistTracks(){
        // Get the tracks for the headerplaylist
        mopidyservice.lookup($scope.headerplaylist.uri).then(function(tracks){
            var frontendtracks = angular.copy(tracks.splice(0,7));
            var tracksloaded = true;

            // Create an artist string for every song
            _.each(frontendtracks, function(track){
                track.artiststring = util.artistsToString(track.artists);<commit_msg>always show first featured playlist<commit_after>'use strict';

angular.module("mopify.discover.featured", [
    "mopify.services.mopidy",
    "mopify.services.spotifylogin",
    "spotify",
    "mopify.services.util",
    "mopify.services.station",
    'mopify.widgets.directive.album'
])

.config(function($routeProvider) {
    $routeProvider.when("/discover/featured", {
        templateUrl: "discover/featured/featured.tmpl.html",
        controller: "DiscoverFeaturedController"
    });
})


.controller("DiscoverFeaturedController", function DiscoverFeaturedController($rootScope, $scope, $timeout, mopidyservice, Spotify, SpotifyLogin, util, stationservice){

    $scope.featuredplaylists = [];
    $scope.titletext = "Loading...";
    $scope.headerplaylist = {};

    // Load the feautured playlists when a connection with mopidy has been established
    $scope.$on("mopidy:state:online", loadFeaturedPlaylists);
    if(mopidyservice.isConnected)
        loadFeaturedPlaylists();

    /**
     * Load all the data for the featured playlists page
     */
    function loadFeaturedPlaylists(){
        // Check if we are logged in to spotify 
        if(SpotifyLogin.connected){
            // Get the featured playlists from spotify
            // TODO: Change the locale to a setting value
            Spotify.getFeaturedPlaylists({
                locale: "nl_NL",
                country: "NL",
                limit: 12
            }).then(function(data){
                // Set the message and items
                $scope.titletext = data.message;
                $scope.featuredplaylists = data.playlists.items;
                $scope.headerplaylist = data.playlists.items[0];

                // Load the tracks for the featured header playlist
                loadHeaderPlaylistTracks();
            });
        }
        else{
            $scope.titletext = "Please connect to Spotify";
        }
    }

    function loadHeaderPlaylistTracks(){
        // Get the tracks for the headerplaylist
        mopidyservice.lookup($scope.headerplaylist.uri).then(function(tracks){
            var frontendtracks = angular.copy(tracks.splice(0,7));
            var tracksloaded = true;

            // Create an artist string for every song
            _.each(frontendtracks, function(track){
                track.artiststring = util.artistsToString(track.artists);
{'fraction_non_alphanumeric': 0.10793183252682516, 'fraction_numerical': 0.0023143277929728594, 'mean_word_length': 2.398141529664046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5519563', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1288, 'n_words': 282}