js/explore/cloud_topics.js
// Turn json obj into desired word list
Turn json obj into desired word list
Turn json obj into desired word list
function reformatData(obj) {
        var wordDict = {};
        var repos = repoNameWOwner == null ? Object.keys(obj['data']) : [repoNameWOwner];
        repos.forEach(function(repo) {
            if (obj['data'].hasOwnProperty(repo)) {
                var topicNodes = obj['data'][repo]['repositoryTopics']['nodes'];
                for (var i = 0; i < topicNodes.length; i++) {
                    var aWord = topicNodes[i]['topic']['name'];
                    if (!Object.keys(wordDict).contains(aWord)) {
                        wordDict[aWord] = 0;
                    }
                    wordDict[aWord] += 1;
                }
            }
        });
        var data = [];
        for (var aWord in wordDict) {
            if (wordDict.hasOwnProperty(aWord)) {
                var datpair = { name: aWord, value: wordDict[aWord] };
                data.push(datpair);
            }
        }
        data.sort((a, b) => (a.value < b.value ? 1 : a.value > b.value ? -1 : 0));
        return data;
    }
function reformatData ( obj ) { var wordDict = { } ; var repos = repoNameWOwner == null ? Object . keys ( obj [ 'data' ] ) : [ repoNameWOwner ] ; repos . forEach ( function ( repo ) { if ( obj [ 'data' ] . hasOwnProperty ( repo ) ) { var topicNodes = obj [ 'data' ] [ repo ] [ 'repositoryTopics' ] [ 'nodes' ] ; for ( var i = 0 ; i < topicNodes . length ; i ++ ) { var aWord = topicNodes [ i ] [ 'topic' ] [ 'name' ] ; if ( ! Object . keys ( wordDict ) . contains ( aWord ) ) { wordDict [ aWord ] = 0 ; } wordDict [ aWord ] += 1 ; } } } ) ; var data = [ ] ; for ( var aWord in wordDict ) { if ( wordDict . hasOwnProperty ( aWord ) ) { var datpair = { name : aWord , value : wordDict [ aWord ] } ; data . push ( datpair ) ; } } data . sort ( ( a , b ) => ( a . value < b . value ? 1 : a . value > b . value ? - 1 : 0 ) ) ; return data ; }
Turn json obj into desired word list
Turn json obj into desired word list
// Prioritize highest counts